Bug in ZipFile implementation


#1

Sometimes, zip files created by Juce’s ZipFile class can’t be uncompressed again by the ZipFile class. There doesn’t seem to be a problem with the zip files themselves as they can be opened using the unzip command or by clicking on them to launch the Archive Utility app on Mac.

Here’s a small sample project containing an example zip file created by the ZipFile class that can’t be opened by the ZipFile class.

http://ftp.eventide.com/ljdl/misc/ZipExtractionProblem.zip

The example zip file is at Builds/MacOSX/ExampleZip.zip.

It should be decompressed to the directory Builds/MacOSX/output

On my Mac running this sample app instead converts the output directory to a file, and the contents of the zip also aren’t enumerated correctly.

The sample app is using the latest Juce 5 modules.


#2

ok… I’m just having a look at this. The first entry seems to contain a zero-length filename, which is throwing everything off, and looks broken to me, but I’ll try to find a way to make it more robust so it can still parse the other entries…


#3

Very annoying - the file contained an incorrect offset for its central directory. Since other readers can cope with it they must already contain a bodge for working around this, so I’ve also added one - it’ll be on develop soon, and seems to work with the file you sent.

What tool did you use to compress it?


#4

The file was created with Juce’s ZipFile class, although it was created using the ZipFile class from Juce 3. We have a feature in one of our apps for exporting your user presets or preset lists as a zip, and what we’ve been seeing is that sometimes users create one of these zip files and can’t import them on other devices using the app.

One user did this using the app on a Windows 64 machine. I’m not sure though if the OS has anything to do with the fact that there is a zero length filename in the zip.


#5

Ah, maybe we had a bug back then. (Ignore what I said about the filename being empty, it turned out to be the incorrect offset that was throwing it all off)


#6

I saw your commit on develop to the ZipFile class. It seems to fix the problem. Thanks a lot!