guzba / zippy

Pure Nim implementation of deflate, zlib, gzip and zip.
MIT License
258 stars 31 forks source link

can't open zip file Unhandled exception: Unsupported zip archive [ZippyError] (deflate64) #11

Open bung87 opened 3 years ago

bung87 commented 3 years ago

https://github.com/bung87/finder/tree/zippy

I previously use std zip lib which works fine and test passed, when switch to zippy I got Unhandled exception: Unsupported zip archive [ZippyError]

the zip file compression through mac context menu, am on platform: macOS nim version: 1.4.4

guzba commented 3 years ago

This happens when the general purpose value has the "data descriptor" bit set. I do not support this now. I've not seen a zip archive with it used. How did you create a the zip archive with this flag set? I'd be curious to see if I can reproduce that and add support and tests for this flag being set.

https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

bung87 commented 3 years ago

I checked the general purpose flag , echo tobin(generalPurposeFlag.int,16) on mac outputs 0000000000001000 https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT described as Bit 4: Reserved for use with method 8, for enhanced deflating.

I compressed directory through mac context menu Compress menu item , don't know the underling software flags. you can check Archive.zip under tests folder , it extract fine with std zip lib and mac The Unarchiver

guzba commented 3 years ago

Hm, it looks like Mac is writing Zip64 files sometimes. I know I've tested with Mac archives that worked fine in the past.

Zip64 are different from standard Zip files even though they share an extension. Zip64 is generally supported in most places. There isn't much for docs on this and they are not clear as to what exactly 'enhanced deflating" is. I'm assuming it means Deflate64 instead of standard Deflate for compression.

Deflate64 is not the same as standard Deflate. It is different enough to require quite a bit of work and is not something I plan to work on in the short term, sorry.

bung87 commented 3 years ago

After google found deflate64 also called "enhanced deflate" is PKWare proprietary, that's why I can't find any open source implementation.

guzba commented 3 years ago

It's interesting that Mac is generating zip archives with enhanced deflate. If we learn more we can add it to this issue. I'm going to add "deflate64" to the issue title too quick.

bung87 commented 3 years ago

yeah , I think std zip module can work because its zip header point to PKWare's header not the open source zlib