Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the 7z sdk to extract rar/zip files (C++)?

Tags:

c++

7zip

I'm trying to write a small, cross-platform comic book reader (Qt / C++). I don't care what's already out there, I know there are some.

My problem is that I need to read the comic book formats, which are renamed rar and zip files.

The documentation is very... nonexistent? There's no "hello archive" document anywho. How can I set this up?

If It makes it easier to assume I'm on any particular OS, do so. I'm switching between Kubuntu, OSX, and Win7 constantly for dev work.

like image 307
Lunarcloud Avatar asked Sep 07 '10 14:09

Lunarcloud


2 Answers

I've been working on a simple C++ wrapper for the 7zip SDK, which you can find here. It currently only supports Windows and the specific needs I had, but I'd be happy to make some alterations and/or accept contributions. It can extract 7zip and Zip files in a few lines of code, using the 7z.dll. RAR shouldn't be difficult to add since the DLL supports it.

like image 82
Chadwick Avatar answered Oct 04 '22 05:10

Chadwick


7z should actually come with both source for a commandline variant and a GUI variant, you could dig into to those and see how they do the compression, else you could use unRar and see if that has any examples(unfortunatly I can't check due to the download being blocked where I am).


Poking around the LMZA SDK a bit I came across this:

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.

like image 38
Necrolis Avatar answered Oct 04 '22 05:10

Necrolis