Jump to content
  • Advertisement
Sign in to follow this  
wicked357

Need a zip library...

This topic is 3079 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 have been doing some research for libraries that handle taking files and essentially putting them in a zip file. I haven't had much luck with what I have found and I am not needing compression. I have checked out zlib, and I read somewhere that Boost does this as well, is that true? If so where do I find it in the documentation about it, it is so huge I really don't want to spend the next week reading through all of it. Also if there is anyone that knows how to do this using zlib that would be nice, I cannot seem to find any kind of tutorials on it I did see the user manual and example they give, maybe I missed something but I didn't find anything specifically for taking multiple files and archiving them, anyone able to help me here?

Share this post


Link to post
Share on other sites
Advertisement
So far I have only seen that to unpack specific files out of a zip and put them into memory, but I didn't see it say anything about creating zip archives and than unzipping them into a directory... maybe I am wrong, but I didn't see anything for that, especially in the example they have doesn't show anything like this.

Share this post


Link to post
Share on other sites
Yeah. PhysFS is a good library for reading in zip files into a game, but it doesn't let you write them.
So the question is, why are your making zipfiles? and why can't you just use a zip program to do so?

I'm going to refer you off to 7-zip. It has a commanline interface that you can use for scripts or whatnot to make the zip files. And if you still need more control than that, read through the licensing as you can incorporate some of their code into your app if you follow their restrictions.

Share this post


Link to post
Share on other sites
Well, normally, you don't really need to save files into an archive from within a game, you'd pack levels, textures, sounds, and whatnot offline using a standard tool (Infozip or Winzip, if nothing else).

Do you REALLY need to write into an archive from your game? Because if you don't, then PhysFS will do the job, and no 3 weeks of reading documentation.

Share this post


Link to post
Share on other sites
Yes in this case I do need to pack and unpack an archive file, I never stated this is for a game, I have already used Physfs for this, but this isn't what I am doing right now. I need a library that is fairly lightweight that handles packing and unpacking, file format doesn't matter at all, could be zip, rar, etc...The problem I have having with other libraries like zlib is lack of documentation, than you have people who put together the zip/unzip header and source but these don't compile without a million errors so I think it is because those are outdated. I noticed Chilkat, but I get like 156 errors just trying to run there first 5 lines of code and I have the most up to date version of it for vc8 and vc9. Anyone have any other suggestions or anything that would be helpful for me here.

Share this post


Link to post
Share on other sites
Yea minizip was what I tried to use, I get a bunch of compiling errors, it isn't that straight forward being heavily reliant on zlib, they assume you are able to run zlib right and I get nothing but compiling errors with that as well, but maybe I am not making the .lib files right. I have tried both versions 1.2.5 and 1.1.4, but I guess I am running out of options because there isn't much documentation on this sort of thing. Thanks for the help, I will try and get zlib working correctly so I can use minizip.

Share this post


Link to post
Share on other sites
You mention VC8 and VC9 so I assume you're developing a Windows app ... in which case I recommend this guy's code. It's a repackaging of part of zlib -- I think with the API tweaked a little bit -- so that it is easier to build and use as part of a Windows app. Very simple to use, I had zero problems with it.

[Edited by - jwezorek on July 16, 2010 5:28:04 AM]

Share this post


Link to post
Share on other sites
Since you said that compression is not necessary, actually why don't you just write your own trivial thing? Something like tar should be a no brainer if the kind of sequential scan is acceptable. Otherwise even something with more straightforward random access is not tough. For example, one could very easily (and in a surprisingly efficient manner) implement such a thing with memory mapping. Just have your "directory" as an array of name + offset pairs (relative to start of data) at the beginning, followed by a little empty space, and then followed by the data. If you run out of "directory space", resize the file by 1-2 kilobytes and do a backwards memcpy on the data part.

I've done similar things in the past, and while you'd expect that inserting data in the middle of a stream and memcpying many megabytes of mapped range would cause major issues and involve a LOT of disk crunching, the OS is surprisingly smart and efficient at doing that kind of thing in reality.

Or, if you think the moving data around could be an issue, you could still put your directory at the end of the file (would have to cache it in RAM and write out again after inserting data), so it would not matter at all. Or, put it into an ADS if you're on Windows.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!