miniz icon indicating copy to clipboard operation
miniz copied to clipboard

[Feature Request] Allow `mz_zip_writer_add_mem_ex_v2` to write metadata without requiring payload (`pBuf`)

Open mikaylagawarecki opened this issue 11 months ago • 0 comments

Hey miniz maintainers,

I am wondering whether it would be feasible for the mz_zip_writer_add_mem_ex_v2 API to only write the metadata associated with the file without requiring pBuf to be defined. In particular, allowing a nullptr for pBuf when buf_size is defined (i.e. compression level 0). Currently, this explicitly errors out here

https://github.com/richgel999/miniz/blob/16413c213de38e703d883006193734e8b1178d5d/miniz_zip.c#L3236

In particular, I am wondering whether the function could write only the zipfile header and central directory entry (excluding CRC_32, which requires the pBuf)

The specific use case I have in mind is as such: We know the size of the entry beforehand and we want to write the metadata associated with the entry in the zipfile while leaving enough empty space for the actual entry to be written later because the buffer is not available at the time we write the metadata.

If it is of interest, I can definitely share more details on my specific use case which relates to PyTorch’s FileWriter that uses miniz.

Would look forward to any feedback on whether the above makes sense and suggestions on how we can do this. If it sounds reasonable, I would be happy to submit the PR that does this! :)

mikaylagawarecki avatar Mar 13 '24 03:03 mikaylagawarecki