Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(zip): indicate that store/desc. entries cant be extracted
- Loading branch information
Showing
2 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace ICSharpCode.SharpZipLib.Zip | ||
{ | ||
/// <summary> | ||
/// General ZipEntry helper extensions | ||
/// </summary> | ||
public static class ZipEntryExtensions | ||
{ | ||
/// <summary> | ||
/// Efficiently check if a <see cref="GeneralBitFlags">flag</see> is set without enum un-/boxing | ||
/// </summary> | ||
/// <param name="entry"></param> | ||
/// <param name="flag"></param> | ||
/// <returns>Returns whether the flag was set</returns> | ||
public static bool HasFlag(this ZipEntry entry, GeneralBitFlags flag) | ||
=> (entry.Flags & (int) flag) != 0; | ||
|
||
/// <summary> | ||
/// Efficiently set a <see cref="GeneralBitFlags">flag</see> without enum un-/boxing | ||
/// </summary> | ||
/// <param name="entry"></param> | ||
/// <param name="flag"></param> | ||
/// <param name="enabled">Whether the passed flag should be set (1) or cleared (0)</param> | ||
public static void SetFlag(this ZipEntry entry, GeneralBitFlags flag, bool enabled = true) | ||
=> entry.Flags = enabled | ||
? entry.Flags | (int) flag | ||
: entry.Flags & ~(int) flag; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters