Skip to content

Zip miniz reader - #3868

Merged
paroj merged 2 commits into
OGRECave:masterfrom
paroj:zip-miniz-reader
Nov 28, 2026
Merged

paroj merged 2 commits into
OGRECave:masterfrom
paroj:zip-miniz-reader

Conversation

@paroj

@paroj paroj commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

fixes #2400

kuba--/zip is only used by ZipArchive for read-only access, and its
reader is a thin layer over miniz's mz_zip_reader_* API. Call miniz
directly instead, which removes about 4k lines of bundled third-party
code and the local patches the wrapper needed.

Entry names are fetched with mz_zip_reader_get_filename into a 64 KiB
buffer, because mz_zip_archive_file_stat truncates m_filename to 512
bytes. Directories are still recognised by their trailing slash rather
than the DOS attribute that miniz also honours. Archives that cannot be
opened now raise an exception instead of being silently treated as
empty.

Also update the bundled miniz to the current master amalgamation
(347653fb1b, after the 3.1.2 release), which carries fixes for the
EOCD scan and zip64 header validation of malformed archives. The
official amalgamation is split into miniz.h and miniz.c, so compile
the implementation from its own translation unit and drop the
MINIZ_HEADER_FILE_ONLY arrangement. Update the license entry to match.
ZipArchive::load used to copy the whole archive into a MemoryDataStream
before handing it to miniz. Pass an Ogre DataStream to
mz_zip_reader_init through its read callback instead: loading then only
reads the central directory, and entry data is read on demand by open().
Embedded archives still wrap their existing buffer, so their bytes are
not copied again on load.

This avoids keeping a second full copy of every zip resource pack in
memory and makes opening an archive proportional to its central
directory rather than to its size.
@paroj
paroj merged commit 80a58c3 into OGRECave:master Nov 28, 2026
9 checks passed
@paroj
paroj deleted the zip-miniz-reader branch November 28, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zip archive always loaded into RAM

1 participant