jaime-olivares / zipstorer

A Pure C# Class to Store Files in Zip
MIT License
183 stars 63 forks source link

`UpdateCrcAndSizes` sets stream position on CanSeek = false streams #15

Closed pgodwin closed 6 years ago

pgodwin commented 7 years ago

Firstly, terrific job with ZipStorer!

I'm just using zip storer a stream that does not support seeking. It looks like UpdateCrcAndSizes sets the position property of a stream, even when CanSeek = false.

According to https://msdn.microsoft.com/en-us/library/system.io.stream.canseek(v=vs.110).aspx "If a class derived from Stream does not support seeking, calls to Length, SetLength, Position, and Seek throw a NotSupportedException."

Sadly, checking the code I'm not sure how to work around it, short of wrapping it in say a buffered stream. Any thoughts?

pgodwin commented 7 years ago

DotNetZip appears to use bit 3 of ZIP64 to work around this. Looks like bit 3 allows specifies that there is a data descriptor after the file data containing the compressed size, uncompressed size and CRC32.

https://dotnetzip.codeplex.com/SourceControl/latest#Zip/ZipEntry.Write.cs

jaime-olivares commented 7 years ago

I will evaluate this feature soon.

jaime-olivares commented 6 years ago

Sorry, there are too much references to the mentioned methods and properties. I don't think this will change.