I want to inflate Microsoft office files using the zlib library. From what I have read, office files are just zip files with extensions like docx,xlsx etc. The unzip utility can actually decompress the files. Can I do the same with the zlib library?
-
1Possible duplicate of [Simple way to unzip a .zip file using zlib](http://stackoverflow.com/questions/10440113/simple-way-to-unzip-a-zip-file-using-zlib) – Mohit Jain Mar 02 '16 at 07:07
-
I want to know if the zlib library is capable of decompressing microsoft office files. I am not looking for how to do it. – user1295872 Mar 02 '16 at 09:10
-
Short answer is no. I would recommend 7-zip free library. – Mohit Jain Mar 02 '16 at 09:24
2 Answers
zlib provides the basic machinery needed to decompress deflate data and to compute CRCs, which is most of what you need to decode zip files. However zlib does not provide zip file format decoding, i.e. decoding the headers, which you would need to wrap around the zlib calls for decompression and check value computation.
zlib does come with minizip, which is in the contrib directory of the source distribution, to do that job. You can also look at libzip or libarchive, which use zlib and which provide zip file functions.

- 101,978
- 13
- 118
- 158
-
Thanks for the answer. I think I have figured out how to do this now. – user1295872 Mar 03 '16 at 10:33
Indeed new office files are in fact .zip files. Not the old .doc and .xls but the new .docx and .xlsx. You can see that if you rename them to .zip and open them. You will then see the contents as .xml files.
A sample code would be something like
HZIP hz = OpenZip(AgentDLLZip, 0, ZIP_FILENAME);
ZIPENTRYW ze;
GetZipItemW(hz, 0, &ze);
UnzipItem(hz, 0, ze.name, 0, ZIP_FILENAME);
CloseZip(hz);
and just use few files you can find here.

- 3,660
- 1
- 33
- 56