Skip to content

Commit

Permalink
Merge 386fc9a into bedd222
Browse files Browse the repository at this point in the history
  • Loading branch information
Draddy1911 committed Jun 22, 2022
2 parents bedd222 + 386fc9a commit 32d7d34
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Zio/FileSystems/ZipArchiveFileSystem.cs
Expand Up @@ -21,6 +21,7 @@ public class ZipArchiveFileSystem : FileSystem
private readonly bool _isCaseSensitive;

private readonly ZipArchive _archive;
private readonly CompressionLevel _compressionLevel;

private readonly ReaderWriterLockSlim _entriesLock = new();

Expand All @@ -47,11 +48,12 @@ public class ZipArchiveFileSystem : FileSystem
/// <param name="archive">An instance of <see cref="ZipArchive" /></param>
/// <param name="isCaseSensitive">Specifies if entry names should be case sensitive</param>
/// <exception cref="ArgumentNullException"></exception>
public ZipArchiveFileSystem(ZipArchive archive, bool isCaseSensitive = false)
public ZipArchiveFileSystem(ZipArchive archive, bool isCaseSensitive = false, CompressionLevel compressionLevel = CompressionLevel.NoCompression)
{
_archive = archive;
_isCaseSensitive = isCaseSensitive;
_creationTime = DateTime.Now;
_compressionLevel = compressionLevel;
if (archive == null)
{
throw new ArgumentNullException(nameof(archive));
Expand Down Expand Up @@ -82,8 +84,8 @@ public ZipArchiveFileSystem(ZipArchive archive, bool isCaseSensitive = false)
/// <param name="mode">Mode of <see cref="ZipArchive" /></param>
/// <param name="leaveOpen">True to leave the stream open when <see cref="ZipArchive" /> is disposed</param>
/// <param name="isCaseSensitive"></param>
public ZipArchiveFileSystem(Stream stream, ZipArchiveMode mode = ZipArchiveMode.Update, bool leaveOpen = false, bool isCaseSensitive = false)
: this(new ZipArchive(stream, mode, leaveOpen), isCaseSensitive)
public ZipArchiveFileSystem(Stream stream, ZipArchiveMode mode = ZipArchiveMode.Update, bool leaveOpen = false, bool isCaseSensitive = false, CompressionLevel compressionLevel = CompressionLevel.NoCompression)
: this(new ZipArchive(stream, mode, leaveOpen), isCaseSensitive, compressionLevel)
{
}

Expand All @@ -94,8 +96,8 @@ public ZipArchiveFileSystem(Stream stream, ZipArchiveMode mode = ZipArchiveMode.
/// <param name="mode">Mode of <see cref="ZipArchive" /></param>
/// <param name="leaveOpen">True to leave the stream open when <see cref="ZipArchive" /> is disposed</param>
/// <param name="isCaseSensitive">Specifies if entry names should be case sensitive</param>
public ZipArchiveFileSystem(string path, ZipArchiveMode mode = ZipArchiveMode.Update, bool leaveOpen = false, bool isCaseSensitive = false)
: this(new ZipArchive(File.Open(path, FileMode.OpenOrCreate), mode, leaveOpen), isCaseSensitive)
public ZipArchiveFileSystem(string path, ZipArchiveMode mode = ZipArchiveMode.Update, bool leaveOpen = false, bool isCaseSensitive = false, CompressionLevel compressionLevel = CompressionLevel.NoCompression)
: this(new ZipArchive(File.Open(path, FileMode.OpenOrCreate), mode, leaveOpen), isCaseSensitive, compressionLevel)
{
}

Expand All @@ -105,8 +107,8 @@ public ZipArchiveFileSystem(string path, ZipArchiveMode mode = ZipArchiveMode.Up
/// <param name="mode">Mode of <see cref="ZipArchive" /></param>
/// <param name="leaveOpen">True to leave the stream open when <see cref="ZipArchive" /> is disposed</param>
/// <param name="isCaseSensitive">Specifies if entry names should be case sensitive</param>
public ZipArchiveFileSystem(ZipArchiveMode mode = ZipArchiveMode.Update, bool leaveOpen = false, bool isCaseSensitive = false)
: this(new ZipArchive(new MemoryStream(), mode, leaveOpen), isCaseSensitive)
public ZipArchiveFileSystem(ZipArchiveMode mode = ZipArchiveMode.Update, bool leaveOpen = false, bool isCaseSensitive = false, CompressionLevel compressionLevel = CompressionLevel.NoCompression)
: this(new ZipArchive(new MemoryStream(), mode, leaveOpen), isCaseSensitive, compressionLevel)
{
}

Expand Down Expand Up @@ -864,7 +866,7 @@ private ZipArchiveEntry CreateEntry(string path)
_entriesLock.EnterWriteLock();
try
{
var entry = _archive.CreateEntry(path);
var entry = _archive.CreateEntry(path, _compressionLevel);

if (!_isCaseSensitive)
{
Expand Down

0 comments on commit 32d7d34

Please sign in to comment.