diff --git a/src/ZlibSharp/Directory.Build.props b/src/ZlibSharp/Directory.Build.props
index bfe0ed6..4bea1a7 100644
--- a/src/ZlibSharp/Directory.Build.props
+++ b/src/ZlibSharp/Directory.Build.props
@@ -3,34 +3,15 @@
- 1.2.13.1
+ 1.2.13.2
true
true
- Added gzip support and more control over how compression/decompression is done based on the input Window Bits.
-
- For simplicity reasons, the Window Bits are stored inside of a ZlibWindowBits enum.
-
- Added types:
- - ZlibCompressionStrategy
- - ZlibWindowBits
-
- Added members in MemoryZlib:
- - IsCompressedByGZip
- - Note: There is no version of the function for raw deflate streams due to the fact that they lack a header and a footer unline zlib/gzip compressed data.
- - GetCompressedSize (works with deflate/zlib/gzip compressed data) No more worrying about over or even under allocating the buffers!!!
- - GetDecompressedSize (works with deflate/zlib/gzip compressed data) No more worrying about over or even under allocating the buffers!!!
-
- Changed members in MemoryZlib:
- - Compress (both versions) adding optional parameters. Please recompile any existing code using these methods as the original would not be found if not recompiled.
- - Decompress (both versions) adding optional parameters. Please recompile any existing code using these methods as the original would not be found if not recompiled.
-
- Internal Changes:
- - Migrated from deflateInit_/inflateInit_ to deflateInit2_/inflateInit2_ zlib apis due to needing more control over the compressed data.
-
- The result:
- - Performance improvement vs using System.IO.Compression.DeflateStream, System.IO.Compression.ZlibStream, and System.IO.Compression.GZipStream and supports more control over how to compress the data unlike those streams which lack said support.
+ A minor bug fix the the previous patch release that fixes the incorect default window bits values in the various MemoryZlib members that were changed/introduced in that update.
+
+ A high performance .NET zlib wrapper that is span based and offers more functionality over System.IO.Compression by allowing more developer control over how the data is compressed and by avoiding .NET's streams entirely.
+
diff --git a/src/ZlibSharp/ZlibSharp/MemoryZlib.cs b/src/ZlibSharp/ZlibSharp/MemoryZlib.cs
index 82f2a2f..220a857 100644
--- a/src/ZlibSharp/ZlibSharp/MemoryZlib.cs
+++ b/src/ZlibSharp/ZlibSharp/MemoryZlib.cs
@@ -38,7 +38,7 @@ public static unsafe class MemoryZlib
/// of the compressed/decompressed results.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ZlibResult Compress(string sourcePath, Span dest, ZlibCompressionLevel compressionLevel = ZlibCompressionLevel.DefaultCompression, ZlibWindowBits windowBits = ZlibWindowBits.Deflate, ZlibCompressionStrategy strategy = ZlibCompressionStrategy.Default)
+ public static ZlibResult Compress(string sourcePath, Span dest, ZlibCompressionLevel compressionLevel = ZlibCompressionLevel.DefaultCompression, ZlibWindowBits windowBits = ZlibWindowBits.Zlib, ZlibCompressionStrategy strategy = ZlibCompressionStrategy.Default)
=> Compress(File.ReadAllBytes(sourcePath), dest, compressionLevel, windowBits, strategy);
///
@@ -58,7 +58,7 @@ public static ZlibResult Compress(string sourcePath, Span dest, ZlibCompre
/// of the compressed/decompressed results.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ZlibResult Compress(ReadOnlySpan source, Span dest, ZlibCompressionLevel compressionLevel = ZlibCompressionLevel.DefaultCompression, ZlibWindowBits windowBits = ZlibWindowBits.Deflate, ZlibCompressionStrategy strategy = ZlibCompressionStrategy.Default)
+ public static ZlibResult Compress(ReadOnlySpan source, Span dest, ZlibCompressionLevel compressionLevel = ZlibCompressionLevel.DefaultCompression, ZlibWindowBits windowBits = ZlibWindowBits.Zlib, ZlibCompressionStrategy strategy = ZlibCompressionStrategy.Default)
{
var bytesWritten = ZlibHelper.Compress(source, dest, compressionLevel, windowBits, strategy, out var adler32);
return new(bytesWritten, 0, adler32);
@@ -79,7 +79,7 @@ public static ZlibResult Compress(ReadOnlySpan source, Span dest, Zl
/// of the compressed/decompressed results.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ZlibResult Decompress(string sourcePath, Span dest, ZlibWindowBits windowBits = ZlibWindowBits.Deflate)
+ public static ZlibResult Decompress(string sourcePath, Span dest, ZlibWindowBits windowBits = ZlibWindowBits.Zlib)
=> Decompress(File.ReadAllBytes(sourcePath), dest, windowBits);
///
@@ -97,7 +97,7 @@ public static ZlibResult Decompress(string sourcePath, Span dest, ZlibWind
/// of the compressed/decompressed results.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ZlibResult Decompress(ReadOnlySpan source, Span dest, ZlibWindowBits windowBits = ZlibWindowBits.Deflate)
+ public static ZlibResult Decompress(ReadOnlySpan source, Span dest, ZlibWindowBits windowBits = ZlibWindowBits.Zlib)
{
var bytesRead = ZlibHelper.Decompress(source, dest, out var bytesWritten, out var adler32, windowBits);
return new ZlibResult(bytesWritten, bytesRead, adler32);
@@ -226,7 +226,7 @@ public static ulong ZlibGetCrc32(ReadOnlySpan data)
///
/// The size of the data when it is compressed.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static uint GetCompressedSize(ReadOnlySpan source, ZlibCompressionLevel compressionLevel = ZlibCompressionLevel.DefaultCompression, ZlibWindowBits windowBits = ZlibWindowBits.Deflate)
+ public static uint GetCompressedSize(ReadOnlySpan source, ZlibCompressionLevel compressionLevel = ZlibCompressionLevel.DefaultCompression, ZlibWindowBits windowBits = ZlibWindowBits.Zlib)
{
var discard = new byte[source.Length];
var result = Compress(source, discard, compressionLevel, windowBits);
@@ -242,7 +242,7 @@ public static uint GetCompressedSize(ReadOnlySpan source, ZlibCompressionL
/// Thrown when zlib errors internally in any way.
///
/// The size of the data when it is decompressed.
- public static uint GetDecompressedSize(ReadOnlySpan source, ZlibWindowBits windowBits = ZlibWindowBits.Deflate)
+ public static uint GetDecompressedSize(ReadOnlySpan source, ZlibWindowBits windowBits = ZlibWindowBits.Zlib)
{
var discard = new byte[Array.MaxLength];
var result = Decompress(source, discard, windowBits);
diff --git a/tests/CompressedText.txt b/tests/CompressedText.txt
index ff8e682..a08541f 100644
Binary files a/tests/CompressedText.txt and b/tests/CompressedText.txt differ
diff --git a/tests/Test.cs b/tests/Test.cs
index 46dc964..589fb11 100644
--- a/tests/Test.cs
+++ b/tests/Test.cs
@@ -83,7 +83,7 @@ public void DecompressionToOverAllocatedBufferShouldHaveBytesWrittenEqualToSourc
[Fact]
public void ZlibSharpVersionWorks()
- => _ = MemoryZlib.ZlibSharpVersion().Should().Be("1.2.13.1");
+ => _ = MemoryZlib.ZlibSharpVersion().Should().Be("1.2.13.2");
[Fact]
public void ZlibVersionWorks()
@@ -95,11 +95,7 @@ public void IsCompressedByZlibWorksAndIsFalse()
[Fact]
public void IsCompressedByZlibWorksAndIsTrue()
- {
- var destBuffer = new byte[MemoryZlib.GetCompressedSize(sourceString)];
- _ = MemoryZlib.Compress(sourceString, destBuffer, windowBits: ZlibWindowBits.Zlib);
- _ = MemoryZlib.IsCompressedByZlib(destBuffer).Should().BeTrue();
- }
+ => _ = MemoryZlib.IsCompressedByZlib("CompressedText.txt").Should().BeTrue();
[Fact]
public void IsCompressedByZlibFailure()