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

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

Open
mikaylagawarecki opened this issue Mar 13, 2024 · 0 comments

Comments

@mikaylagawarecki
Copy link

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

miniz/miniz_zip.c

Line 3236 in 16413c2

if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION))

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! :)

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

No branches or pull requests

1 participant