Add ZIP64 footer support for archives with more than 65,535 files#270
Add ZIP64 footer support for archives with more than 65,535 files#270cyfung1031 wants to merge 11 commits into
Conversation
Merge #270 to close #229#270 fixes the >65,535-file bug in ~50 lines, on current Why #270
The askNot "drop #230" — just sequence it:
At a glance
|
Since this isn't a full fix for ZIP64 support, I would generally rather implement the changes in #230 than this. But you're right that this is a much smaller change and it largely looks good. I might implement a combination of these two PRs if this implements >65536 files more efficiently than #230. Please avoid massive AI-generated PR descriptions for the future; it's a lot easier and faster to read a more precise description written by a human. |
Summary
This PR adds ZIP64 end-of-central-directory support when creating ZIP archives that contain more than 65,535 entries.
Close #229
Previously, ZIP creation always wrote the classic EOCD record only. Because the classic EOCD stores entry counts in 16-bit fields, archives with more than
0xFFFFfiles would overflow/truncate the file count and could not be read correctly by ZIP tools.Changes
Add ZIP64 EOCD record generation when the archive requires it.
Add ZIP64 EOCD locator generation.
Keep the classic EOCD record for compatibility, using ZIP64 sentinel values when needed.
Allocate the correct footer size for:
ZipzipzipSyncAdd a regression test for creating and reading an archive with 65,536 files.
Notes
This fixes the ZIP entry-count limit. It does not attempt to fully ZIP64-enable per-file local or central-directory headers for individual file sizes or offsets above
0xFFFFFFFF; those would require separate ZIP64 extra-field handling in file headers.Testing
Added coverage for an archive with 65,536 empty files to verify that:
Reference Testing:
jszip-limit-test.html
fflate-zipsync-limit-test.html
fflate-streaming-zip-limit-test.html
Before
After