[SOLVED] Creating a zip file

Hello,

How do you create ZIP files in your JUCE apps?

The juce::ZipFile seems to produce broken packages if the package size exceeds 4GB. I’ve looked for alternatives, but haven’t found any that wouldn’t require building, installing and integrating a bunch of 3rd party libraries.

Solutions based on Zlib look quite complicated to get working in JUCE. I see there’s even a built in Zlib in JUCE, but don’t really see how that could be used to back a C++ wrapper library that needs to be built externally and linked e.g. libzip.

I’m sure many of you create large zip files in your JUCE apps. How do you do it?

For anyone stumbling here in hope for a solution, i ended up with miniz library. It’s just a pair of header and implementation files you can drop into your JUCE project and it seems to compile and work on MacOS and Windows without any issues.

It’s a C API so not the most comfortable, but all i needed to do is to call mz_zip_add_mem_to_archive_file_in_place for every file and the rest seems to just work.

The only thing that’s not completely obvious is, that in order to make the ZIP survive the 4GB limit, you need to explicitly set MZ_ZIP_FLAG_WRITE_ZIP64 flag by passing it to the above function (along with any other flags such as the compression level etc).

Maybe there’s some similar flag in juce::ZipFile::Builder, but i couldn’t find it.

1 Like

This was requested in the past but nothing has been done yet, see JUCE doesn't support Zip64

1 Like

Sadly it’s not the first bug that JUCE has just been ignoring for years and me spending hours debugging issues, reported by clients and customers, with delivered products. A note in the docs would be decent, not to mention if these we’re fixed. For a while i thought i was lucky to have zip file support built in JUCE. :rofl:

ZipFile::Builder