nih-at / libzip

A C library for reading, creating, and modifying zip archives.
https://libzip.org/
Other
832 stars 270 forks source link

Support non-seekable output #378

Open kleisauke opened 1 year ago

kleisauke commented 1 year ago

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 https://github.com/nih-at/libzip/blob/b3ac716c0154cdbd70af1daf254adcccd16cb80a/lib/zip_close.c#L380-L381

dillof commented 1 year ago

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 ;).