@@ -32,9 +32,6 @@ public bool Extract(Stream? stream, string file, string outDir, bool includeDebu
3232#if NET20 || NET35 || ! WIN
3333 try
3434 {
35- if ( ! File . Exists ( file ) )
36- return false ;
37-
3835 // Create the wrapper
3936 var cabArchive = SabreTools . Serialization . Wrappers . MicrosoftCabinet . Create ( stream ) ;
4037 if ( cabArchive ? . Model ? . Folders == null || cabArchive . Model . Folders . Length == 0 )
@@ -48,6 +45,10 @@ public bool Extract(Stream? stream, string file, string outDir, bool includeDebu
4845 if ( folder ? . DataBlocks == null || folder . DataBlocks . Length == 0 )
4946 continue ;
5047
48+ // Setup decompressors
49+ var mszip = SabreTools . Compression . MSZIP . Decompressor . Create ( ) ;
50+ uint quantumWindowBits = ( uint ) ( ( ( ushort ) folder . CompressionType >> 8 ) & 0x1f ) ;
51+
5152 // Loop through the data blocks
5253 var ms = new MemoryStream ( ) ;
5354 foreach ( var db in folder . DataBlocks )
@@ -65,16 +66,14 @@ public bool Extract(Stream? stream, string file, string outDir, bool includeDebu
6566 // MS-ZIP
6667 else if ( ( folder . CompressionType & CompressionType . TYPE_MSZIP ) != 0 )
6768 {
68- var decomp = SabreTools . Compression . MSZIP . Decompressor . Create ( ) ;
69- decomp . CopyTo ( db . CompressedData , ms ) ;
69+ mszip . CopyTo ( db . CompressedData , ms ) ;
7070 }
7171
7272 // Quantum
7373 else if ( ( folder . CompressionType & CompressionType . TYPE_QUANTUM ) != 0 )
7474 {
75- uint windowBits = ( uint ) ( ( ( ushort ) folder . CompressionType >> 8 ) & 0x1f ) ;
76- var decomp = SabreTools . Compression . Quantum . Decompressor . Create ( db . CompressedData , windowBits ) ;
77- byte [ ] data = decomp . Process ( ) ;
75+ var quantum = SabreTools . Compression . Quantum . Decompressor . Create ( db . CompressedData , quantumWindowBits ) ;
76+ byte [ ] data = quantum . Process ( ) ;
7877 ms . Write ( data , 0 , data . Length ) ;
7978 ms . Flush ( ) ;
8079 }
0 commit comments