Skip to main content
$12256 / $11500
About
Rules
Blog
FAQ
Style
Forum
Open files from a zip
Programming
Open files from a zip
Buch
Wednesday, December 1, 2010 - 11:10
Is there a way to open a file inside a compressed zip in c++?
Look into zlib. I think it can do that, although I'm not 100% certain. What I can tell you is that I'm virtually certain there are some libraries that allow you to do it.
I don't think C or C++ native libraries have zip support.
Probably zlib is the way to go: http://www.zlib.net/
It really depends on how you define "zip file". There are two different things:
zlib, and many other libraries (libbz2, minilzo, fastlzo, ...) only do the latter: compress a single file.
I guess by "zip file" you are talking about the compressed archive files that the "winzip" and co. produces, that has the .zip extension? If that is a case, zlib is not what you want. But you have several other choices of libraries:
Hope this helps :)
I was meaning exactly files with the .zip extension. Since I'm quite new at programming, I'd like something not too complicated to learn...
What I want is to read a file inside a zip archive (with different files and even directories, if possible) copying it in temporary memory but without creating a copy of that file on the hard disk.
Anyway, I'm gonna try out those libraries... maybe one of them supplies my needs
Had a quick look at "minizip" (the link labeled "1.1" on their website), file miniunz.c, the function "do_extract_onefile" does what you want. You might just copy-paste that function (and the ones it uses) and use it. (But don't forget the copyright)
I would suggest, Physicsfs, since it is a ready-to-go solution: http://icculus.org/physfs/