Skip to main content

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password
Register
  • Home
  • Browse
    • 2D Art
    • 3D Art
    • Concept Art
    • Textures
    • Music
    • Sound Effects
    • Documents
    • Featured Tutorials
  • Submit Art
  • Collect
    • My Collections
    • Art Collections
  • Forums
  • FAQ
  • Leaderboards
    • All Time
      • Total Points
      • Comments
      • Favorites (All)
      • Favorites (2D)
      • Favorites (3D)
      • Favorites (Concept Art)
      • Favorites (Music)
      • Favorites (Sound)
      • Favorites (Textures)
    • Weekly
      • Total Points
      • Comments
      • Favorites (All)
      • Favorites (2D)
      • Favorites (3D)
      • Favorites (Concept Art)
      • Favorites (Music)
      • Favorites (Sound)
      • Favorites (Textures)
  • ❤ Donate
Programming

Open files from a zip

Buch
Wednesday, December 1, 2010 - 08:10
Buch's picture

Is there a way to open a file inside a compressed zip in c++?

  • Log in or register to post comments
bart
joined 13 years 11 months ago
Wednesday, December 1, 2010 - 08:22
bart's picture

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.

  • Log in or register to post comments
Clint Bellanger
joined 15 years 8 months ago
Wednesday, December 1, 2010 - 08:29
Clint Bellanger's picture

I don't think C or C++ native libraries have zip support.

Probably zlib is the way to go: http://www.zlib.net/

  • Log in or register to post comments
Pompei2
joined 15 years 6 months ago
Wednesday, December 1, 2010 - 13:52
Pompei2's picture

It really depends on how you define "zip file". There are two different things:

 

  1. Archives: a file that contains several files, and possibly directories.
  2. Compressed files: a single file that is compressed using some algorithm.

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:

  • zziplib
  • minizip
  • 7zip SDK (a beast but has probably the best compression ratios)
  • XZip (windows only)

Hope this helps :)

 

  • Log in or register to post comments
Buch
joined 14 years 9 months ago
Thursday, December 2, 2010 - 04:38
Buch's picture

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


  • Log in or register to post comments
Pompei2
joined 15 years 6 months ago
Thursday, December 2, 2010 - 06:19
Pompei2's picture

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)

  • Log in or register to post comments
LeeZH
joined 14 years 10 months ago
Friday, December 31, 2010 - 04:35
LeeZH's picture

I would suggest, Physicsfs, since it is a ready-to-go solution: http://icculus.org/physfs/

  • Log in or register to post comments