Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZipFile : Add support for Zip64 (Compressed file over 4GB) #1271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add support for zip64 format
  • Loading branch information
flyingrub committed Sep 7, 2022
commit b849feb33dbcec795fee91c3d4dd88af2c41cd86
22 changes: 22 additions & 0 deletions modules/juce_core/zip/juce_ZipFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ struct ZipFile::ZipEntryHolder
entry.isSymbolicLink = (fileType == 0xA);

entry.filename = String::fromUTF8 (buffer + 46, fileNameLen);

auto const extraFieldLength = ByteOrder::littleEndianShort(buffer + 30);
if (extraFieldLength != 0)
{
auto extraFieldOffset = 0;
auto* extraHeaderPtr = buffer + 46 + fileNameLen;
auto* extraSectionPtr = extraHeaderPtr;
while (extraFieldOffset < extraFieldLength) {
auto extraHeaderTag = ByteOrder::littleEndianShort(extraSectionPtr);
auto extraFieldSectionLength = ByteOrder::littleEndianShort(extraSectionPtr + 2);
if (extraHeaderTag == 0x0001) // Zip64 Tag
{
entry.uncompressedSize = (int64)ByteOrder::littleEndianInt64(extraSectionPtr + 4);
if (extraFieldSectionLength > 8)
compressedSize = (int64)ByteOrder::littleEndianInt64(extraHeaderPtr + 12);
if (extraFieldSectionLength > 16)
streamOffset = (int64)ByteOrder::littleEndianInt64(extraHeaderPtr + 20);
}
extraFieldOffset += extraFieldSectionLength + 4;
extraSectionPtr = extraHeaderPtr + extraFieldOffset;
}
}
}

static Time parseFileTime (uint32 time, uint32 date) noexcept
Expand Down