7-Zip: Any good tutorials? [closed]
Asked Answered
Y

1

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.
Yippee answered 3/6, 2011 at 11:19 Comment(12)
It is open source, the source code is the documentation.Quenby
@Hans I shouldn't have to know how it works, in order to know how to use it. Just my opinion.Yippee
How about just shelling it out?Fioritura
@Fioritura I don't know what you mean. [Edit after looking at definition of "shell out".] Who should I pay and for what?Yippee
@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.Gladygladys
@Gladygladys 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.Yippee
@Paul the shell out call can be 'invisible'. fyi: dotnetperls.com/7-zip-examplesFioritura
@Fioritura 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. :)Yippee
@Fioritura 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.Yippee
OK cool. You certainly can distribute the 7z binaries as part of your app, but it sounds like your on a better path.Fioritura
@PaulManta - how did you do with this? Great success? Utter failure? I'm at exactly the same point as you were - any tips?Blunderbuss
@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!Yippee
S
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.

Sapro answered 3/6, 2011 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.