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

Support non-seekable output #378

Open
kleisauke opened this issue May 4, 2023 · 1 comment
Open

Support non-seekable output #378

kleisauke opened this issue May 4, 2023 · 1 comment
Labels
enhancement Request a new feature. help wanted

Comments

@kleisauke
Copy link

Description
For writing, it's currently mandatory to provide the ZIP_SOURCE_SEEK_WRITE and ZIP_SOURCE_TELL_WRITE commands in zip_source_callback.

Solution
Allow non-seekable output by making these commands optional. When the output is not seekable one can write a 'streamed' ZIP (by setting bit 3 of the general purpose bit flag) with the CRC-32, compressed size and uncompressed size filled with zero in the local header. The correct values are put in the data descriptor immediately after the compressed data.

Additional context

libzip/lib/zip_close.c

Lines 380 to 381 in b3ac716

/* as long as we don't support non-seekable output, clear data descriptor bit */
de->bitflags &= (zip_uint16_t)~ZIP_GPBF_DATA_DESCRIPTOR;

@dillof
Copy link
Member

dillof commented Jun 9, 2023

This won't work for modifying existing zip archives (since I don't see a way to replace the original archive with the new one), but for creating new archives it would be a meaningful enhancement.

So we're not opposed to adding this functionality, but it's not high on our priority list. Patches are welcome ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request a new feature. help wanted
Projects
None yet
Development

No branches or pull requests

3 participants