richgel999 / miniz

miniz: Single C source file zlib-replacement library, originally from code.google.com/p/miniz
MIT License
2.18k stars 322 forks source link

Set external attributes when adding a file #116

Open gaborcsardi opened 5 years ago

gaborcsardi commented 5 years ago

So that one can set uid/gid and permissions. AFAICT this is currently not possible, but please FIXME.

gaborcsardi commented 5 years ago

If you would like to have proper API to set the external attributes and other fields, when creating an archive, I'll be happy to send a PR.

uroni commented 5 years ago

I have added the extra_data parameters with miniz 2 when adding files. I have nothing against functions to contruct said extra data. It's just hard to find a specification for them. https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT has some, but not many.

In this case it would be something like "Info-ZIP UNIX (new)" ?

gaborcsardi commented 5 years ago

One way to go about it is to have a "raw' api, where people can supply arbitrary bytes to set. I did that in my project: https://github.com/r-lib/zip/blob/027d05ff911f0c2a1e5bda7014438efee609572d/src/miniz.c#L3962-L4000

Then you could add some helper functions that create the appropriate attribute for given uid/gid and permissions.