Skip to content

Commit d8cb94e

Browse files
committed
Add local changes
+ Adding x86 support + Moving from in-repo ZstdNet code to NuGet package + Explicitly use FileStream as an argument for CombinedStream
1 parent 7940575 commit d8cb94e

23 files changed

Lines changed: 729 additions & 999 deletions

SharpHDiffPatch.Core/Binary/Compression/CompressionStreamHelper.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
using SharpCompress.Compressors.LZMA;
33
using SharpHDiffPatch.Core.Binary.Streams;
44
using System;
5+
#if NET6_0_OR_GREATER
56
using System.Collections.Generic;
7+
#endif
68
using System.IO;
79
using System.IO.Compression;
810
using System.Runtime.InteropServices;
@@ -34,6 +36,7 @@ internal static class CompressionStreamHelper
3436
{
3537
private delegate Stream ZstdStreamFallback(Stream stream);
3638
private static ZstdStreamFallback CreateZstdStreamFallback;
39+
private static readonly int _zstdWindowLogMax = Environment.Is64BitProcess ? 31 : 30;
3740

3841
internal static void GetDecompressStreamPlugin(CompressionMode type, Stream sourceStream, out Stream decompStream,
3942
long length, long compLength, out long outLength, bool isBuffered)
@@ -83,7 +86,7 @@ private static Stream CreateZstdStream(Stream rawStream)
8386
if (CreateZstdStreamFallback == null)
8487
{
8588
#if !(NETSTANDARD2_0_OR_GREATER || NET461_OR_GREATER)
86-
if (Extern.IsLibraryExist(ZstdNet.ExternMethods.DllName))
89+
if (ZstdNet.DllUtils.IsLibraryExist(ZstdNet.DllUtils.DllName))
8790
CreateZstdStreamFallback = CreateZstdNativeStream;
8891
else
8992
CreateZstdStreamFallback = CreateZstdManagedStream;
@@ -104,14 +107,14 @@ private static Stream CreateZstdStream(Stream rawStream)
104107
private static Stream CreateZstdNativeStream(Stream rawStream) =>
105108
new ZstdNativeStream(rawStream, new ZstdNativeDecompressor(null, new Dictionary<ZstdNativeDecompressorParameter, int>()
106109
{
107-
{ ZstdNativeDecompressorParameter.ZSTD_d_windowLogMax, 31 }
110+
{ ZstdNativeDecompressorParameter.ZSTD_d_windowLogMax, _zstdWindowLogMax }
108111
}), 0);
109112
#endif
110113

111114
private static Stream CreateZstdManagedStream(Stream rawStream)
112115
{
113116
ZstdManagedDecompressor decompressor = new ZstdManagedDecompressor();
114-
decompressor.SetParameter(ZstdManagedDecompressorParameter.ZSTD_d_windowLogMax, 31);
117+
decompressor.SetParameter(ZstdManagedDecompressorParameter.ZSTD_d_windowLogMax, _zstdWindowLogMax);
115118
return new ZstdManagedStream(rawStream, decompressor, 16 << 10);
116119
}
117120

SharpHDiffPatch.Core/Binary/Compression/Zstd/Consts.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

SharpHDiffPatch.Core/Binary/Compression/Zstd/DecompressionOptions.cs

Lines changed: 0 additions & 72 deletions
This file was deleted.

SharpHDiffPatch.Core/Binary/Compression/Zstd/DecompressionStream.cs

Lines changed: 0 additions & 229 deletions
This file was deleted.

0 commit comments

Comments
 (0)