Skip to content

decompressZip overloads returning files via a callback - #7102

Merged
Fedr merged 2 commits into
masterfrom
decompress-zip-callback
Oct 12, 2026
Merged

Fedr merged 2 commits into
masterfrom
decompress-zip-callback

Conversation

@Fedr

@Fedr Fedr commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Adds decompressZip overloads (zip file path and std::istream) that pass every file of the archive to a callback instead of saving it on disk:

using ZipFileCallback = std::function<Expected<void>( const std::string& path, std::vector<char>&& data )>;
  • path is relative inside the archive with / separators; folder entries and macOS __MACOSX/ metadata are skipped.
  • An error returned by the callback stops decompression and is passed to the caller.
  • The entry loop is factored out into forEachZipEntry_, shared with the existing folder-extracting decompressZip; the zip entry is now closed also when reading it fails.
  • Fix in the std::istream zip source: ZIP_SOURCE_STAT returned the size from the current stream position to the end instead of the whole stream size. libzip stats the source also when opening an entry, in the middle of the stream, and on macOS failed to open the second entry. The bug was in the existing stream decompressZip too; the new test is the first to cover it.
  • "Cannot open zip file" error now includes libzip's error message.
  • New test MRMesh.DecompressZipToCallback.

🤖 Generated with Claude Code

Fedr and others added 2 commits October 10, 2026 14:56
…ving it on disk

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_STAT

libzip stats the source also in the middle of reading (when opening an entry),
and getStreamSize returned only the size from the current position to the end;
macOS libzip then failed to open the second entry of a stream.
Also add libzip's error to "Cannot open zip file" message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fedr
Fedr merged commit 54d08c6 into master Oct 12, 2026
118 of 119 checks passed
@Fedr
Fedr deleted the decompress-zip-callback branch October 12, 2026 08:48
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.

2 participants