zlib file inflation

Started by
7 comments, last by Mulligan 20 years, 1 month ago
When inflating a file that was compressed using zlib, how do i know how bug the buffer should be to hold the uncompressed data?
Advertisement
Ive only ever used the unzip part of Zlib but if you open and locate the file inside the zip file you want to read into memory you can get the file info like so:

unz_file_info	g_ZFileInfo;unzFile  g_ZipFile;//open zip file with g_ZipFile//locate the file you want to read into memory//get the files infounzGetCurrentFileInfo(g_ZFile, &g_ZFileInfo, NULL, 0, NULL, 0, NULL, 0);//create a buffer big enough for the filevoid *g_pBuffer = malloc(g_ZFileInfo.uncompressed_size); 




[edited by - Spudder on February 28, 2004 4:51:46 PM]
is that zlib?
all those variables and functions are undefined when i try to use them.
thats using Gilles Vollants unzip portion of Zlib, need to #include "unzip.h"
thanks, this looks like what im looking for.

crap, does that mean i have to include all of those source files into my project as well? I downloaded the what you told me to and have included "unzip.h", but get unresloved externals. I dont see any library files or dll's to link to my project.


[edited by - Mulligan on February 28, 2004 5:07:27 PM]
all you need to do is to link to either the zlib static or dll library and include unzip.h and thats it
hum, not workin for me. I''m using (what i think) is a standard zlib dll. Do i have to get a special dll for Gilles Vollants unzip stuff?

Thanks for the info so far, quite helpful.
You can get the zip/unzip package from here, i'm using Zlib version 1.1.4 and it works perfectly for me.

EDIT: you dont need any separate library for the unzip package, all you need is to #include "unzip.h" (available from the site above) and make sure you link to the zlib library from your project

[edited by - Spudder on February 29, 2004 8:27:31 AM]
ahha, thanks. Seems that in the newest version there is no unzip, so im using the older version that you said you were using and it works. Thanks!

This topic is closed to new replies.

Advertisement