File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,7 +330,7 @@ bool closeStream
330330 protected override IReader CreateReaderForSolidExtraction ( )
331331 {
332332 var stream = Volumes . Single ( ) . Stream ;
333- stream . Position = 0 ;
333+ ( ( IStreamStack ) stream ) . StackSeek ( 0 ) ;
334334 return ZipReader . Open ( stream , ReaderOptions , Entries ) ;
335335 }
336336}
Original file line number Diff line number Diff line change @@ -50,7 +50,6 @@ internal BinaryReader FixStreamedFileLocation(ref SharpCompressStream rewindable
5050 if ( _decompressionStream is DeflateStream deflateStream )
5151 {
5252 ( ( IStreamStack ) rewindableStream ) . StackSeek ( 0 ) ;
53- //rewindableStream.Rewind(deflateStream.InputBuffer);
5453 }
5554
5655 Skipped = true ;
Original file line number Diff line number Diff line change @@ -22,7 +22,19 @@ internal IEnumerable<ZipHeader> ReadStreamHeader(Stream stream)
2222 {
2323 if ( stream is not SharpCompressStream ) //ensure the stream is already a SharpCompressStream. So the buffer/size will already be set
2424 {
25- throw new ArgumentException ( "Stream must be a SharpCompressStream" , nameof ( stream ) ) ;
25+ //the original code wrapped this with RewindableStream. Wrap with SharpCompressStream as we can get the buffer size
26+ if ( stream is SourceStream src )
27+ {
28+ stream = new SharpCompressStream (
29+ stream ,
30+ src . ReaderOptions . LeaveStreamOpen ,
31+ bufferSize : src . ReaderOptions . BufferSize
32+ ) ;
33+ }
34+ else
35+ {
36+ throw new ArgumentException ( "Stream must be a SharpCompressStream" , nameof ( stream ) ) ;
37+ }
2638 }
2739 SharpCompressStream rewindableStream = ( SharpCompressStream ) stream ;
2840
Original file line number Diff line number Diff line change @@ -252,6 +252,25 @@ IEnumerable<string> testArchives
252252 }
253253 }
254254
255+ protected void ArchiveExtractToDirectory (
256+ string testArchive ,
257+ ReaderOptions ? readerOptions = null
258+ ) => ArchiveExtractToDirectory ( ArchiveFactory . AutoFactory , testArchive , readerOptions ) ;
259+
260+ protected void ArchiveExtractToDirectory (
261+ IArchiveFactory archiveFactory ,
262+ string testArchive ,
263+ ReaderOptions ? readerOptions = null
264+ )
265+ {
266+ testArchive = Path . Combine ( TEST_ARCHIVES_PATH , testArchive ) ;
267+ using ( var archive = archiveFactory . Open ( new FileInfo ( testArchive ) , readerOptions ) )
268+ {
269+ archive . ExtractToDirectory ( SCRATCH_FILES_PATH ) ;
270+ }
271+ VerifyFiles ( ) ;
272+ }
273+
255274 protected void ArchiveFileRead (
256275 IArchiveFactory archiveFactory ,
257276 string testArchive ,
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ ReaderOptions options
4747 {
4848 UseReader ( reader , expectedCompression ) ;
4949 protectedStream . ThrowOnDispose = false ;
50- Assert . False ( testStream . IsDisposed , "{nameof(testStream)} prematurely closed" ) ;
50+ Assert . False ( testStream . IsDisposed , $ "{ nameof ( testStream ) } prematurely closed") ;
5151 }
5252
5353 // Boolean XOR -- If the stream should be left open (true), then the stream should not be diposed (false)
Original file line number Diff line number Diff line change @@ -88,6 +88,10 @@ public void WinZip26_X_Multi_ArchiveFileRead() =>
8888 [ Fact ]
8989 public void Zip_Deflate_ArchiveFileRead ( ) => ArchiveFileRead ( "Zip.deflate.zip" ) ;
9090
91+ [ Fact ]
92+ public void Zip_Deflate_ArchiveExtractToDirectory ( ) =>
93+ ArchiveExtractToDirectory ( "Zip.deflate.zip" ) ;
94+
9195 //will detect and load other files
9296 [ Fact ]
9397 public void Zip_Deflate_Multi_ArchiveFirstFileRead ( ) =>
You can’t perform that action at this time.
0 commit comments