19

I'm thinking about using the 7-Zip format to pack my application files since it's a very compact and popular format. I can't find some tutorials on how to use the C++ SDK, though. I'd like some tutorials that teach me how to:

  • Open an archive from memory (buffer) instead of directly from disk.
  • Extract individual files inside the archive, to buffer, not to disk.
  • Check if a certain file can be found in the archive.
Paul Manta
  • 30,618
  • 31
  • 128
  • 208
  • It is open source, the source code is the documentation. – Hans Passant Jun 03 '11 at 12:15
  • 25
    @Hans I shouldn't have to know how it works, in order to know how to use it. Just my opinion. – Paul Manta Jun 03 '11 at 12:20
  • How about just shelling it out? – kenny Jun 03 '11 at 12:55
  • @kenny I don't know what you mean. [Edit after looking at definition of "shell out".] Who should I pay and for what? – Paul Manta Jun 03 '11 at 13:06
  • @Paul Shell out in this case means using your platform's shell to call the executable instead of using the API. Under Windows this means using the system function and passing it in a command to execute. – stonemetal Jun 03 '11 at 13:19
  • @stonemetal Oh, I see. That's not an option; I'm writing a game which may go cross-platform at some time, so using the shell is not a viable alternative. – Paul Manta Jun 03 '11 at 13:51
  • @Paul the shell out call can be 'invisible'. fyi: http://www.dotnetperls.com/7-zip-examples – kenny Jun 03 '11 at 14:00
  • @kenny I know it can, but it's just an inelegant unmaintainable solution, given what my project is. I have to either force the player to install 7-Zip or assume they already have it installed. Neither option is to my liking. :) – Paul Manta Jun 03 '11 at 14:30
  • @kenny Besides, I think I'm starting to understand how to use it. I'll post my own answer if I do manage to get this working. – Paul Manta Jun 03 '11 at 14:32
  • OK cool. You certainly can distribute the 7z binaries as part of your app, but it sounds like your on a better path. – kenny Jun 03 '11 at 17:16
  • 2
    @PaulManta - how did you do with this? Great success? Utter failure? I'm at exactly the same point as you were - any tips? – Ben Nov 08 '12 at 03:45
  • 2
    @Steve Unfortunately, I haven't been able to find any good learning resource. I was able to understand how to use it eventually, by learning from various sources and examples, but I'm pretty sure I could have written better code if I understood the library better. Good luck! – Paul Manta Nov 08 '12 at 06:45

1 Answers1

5

From the LMZA SDK documentation:

ANSI-C LZMA Decoder

~~~~~~~~~~~~~~~~~~~

Please note that interfaces for ANSI-C code were changed in LZMA SDK 4.58. If you want to use old interfaces you can download previous version of LZMA SDK from sourceforge.net site.

To use ANSI-C LZMA Decoder you need the following files: 1) LzmaDec.h + LzmaDec.c + Types.h

LzmaUtil/LzmaUtil.c is example application that uses these files.

The example app should have everything you need, else the actual source for 7-zip will have what you need. There is also a C++ wrapper for 7-zip here which should simplify a lot of the needed ops.

Necrolis
  • 25,836
  • 3
  • 63
  • 101