I am trying to compress files using libzip and I seem to succeed but I cannot seem to figure out a way to change the compression level (zip tool supports values from 1(fastest compression speed) to 9 (smallest archive)) which I must reimplement. Is there a way to do so?
Asked
Active
Viewed 1,663 times
1 Answers
0
See ZIP_CM_*
defines in zip.h
, and struct zip_stat
and its comp_method
field.

Bogdan
- 984
- 8
- 16
-
1zip_set_file_compression(zipArchivePtr, fileIndex, ZIP_CM_*, 0) seems to be indeed the way (where fileIndex is as retrieved from zip_file_add) but currenly only ZIP_CM_STORE produces different archive size all [ZIP_CM_SHRINK, ZIP_CM_DEFLATE] produce the archive of the same size. Thank you for pointing out that there are other flags that are not in the documentation. – Apr 28 '14 at 15:10
-
It's strange. It uses zlib and I cannot believe that zlib ignores compression level. I would check if casual zip tool which uses zlib produces different archives for your data. I've only evaluated libzip, I decided to use minizip, thus I cannot check if your problem is reproducible. – Bogdan Apr 28 '14 at 17:16
-
minizip does use zlib and then the compression level works perfectly. libzip is a separate library and I am currently only evaluating it also. So far I am also inclined to prefer minizip. – Apr 29 '14 at 09:01
-
@typical Surprisign, libzip includes zlib.h so I assumed it uses zlib. Sorry for misleading clue. – Bogdan Apr 29 '14 at 09:20