Jump to content
  • Advertisement
Sign in to follow this  
sckoobs

zlib Compress multiple files into one

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking into using zlib to compress all of my game data files. I've seen some of the examples of zlib and read pieces of the manual and it all looks pretty straight forward. I'm looking to use zlib for a slightly different purpose however, rather than compress multiple files into multiple files I want to compress multiple files into one file (similar to common zip utility compression archives I'd imagine) and be able to open that file in the initialisation of my program and be able to read each of the compressed files back into memory for normal use. The problem that I see arising is that I'll have my compressed file containing all of the other files, but how do I distinguish between the files in code when I'm loading them from the compressed file? I had thought of making my own headers that I'll write into the compressed file, but I get the feeling that zlib might already take care of this for me? As my knowledge of zlib is very limited (considering I've only just started looking at it) I was wondering how this might be achieved and if anyone knows of any tutorials/examples that specifically deal with this scenario, as all the examples I've seen so far seem to compress only one file into another. Cheers, Andy.

Share this post


Link to post
Share on other sites
Advertisement
Hey bud,

There is this article here on gamedev that shows you how to use the PAK file format. I believe this packing format was used in Quake and other games of that genre. Though i believe that now CAB is the preferred format.

Hope that helps,

Dave

Share this post


Link to post
Share on other sites
I use a PAK file format, except each file can be compressed with either zlib or bzip2. Usually, the file size ends up about the same size as just zipping the folder.

Share this post


Link to post
Share on other sites
Google for zzip (somewhere on sourceforge) or minizip (example
code in the zlib source-release).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!