22using SharpCompress . Compressors . LZMA ;
33using SharpHDiffPatch . Core . Binary . Streams ;
44using System ;
5+ #if NET6_0_OR_GREATER
56using System . Collections . Generic ;
7+ #endif
68using System . IO ;
79using System . IO . Compression ;
810using 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
0 commit comments