Extract tar in memory and nonblocking - c++

I need to extract a tar.gz datastream in memory. An additional limit is that I cannot block.
Deflating in memory works great via zlib.
Now I need the untar part. Sadly all libraries I found either block or just work with tar files. Is there any library that works similarly to zlib?

Ok, there was no suitable library before. But now there will be, soon.
Check it out here but be aware, that it is not yet working.

Related

how do I decompress tar.gz file using c++ program

In my linux program, I want to decompress a tar.gz file contents to a specific directory. Is there any system call or any C++ class available in C/C++ to extract file contents from tar.gz file?
There is excellent library libarchive, which supports accessing multiple archive formats using consistent API. You can follow these examples on how to use it.
If you are on Ubuntu, you can easily install this library using command sudo apt-get install libarchive-dev. On other platforms, you may need to download source code and compile this library yourself.
One advantage of using libarchive vs. using system() calls is not depending on system utilities, and also it should work faster because it does not fork.
You can use several libs like libtar.
Or you can use a system call like you already mentioned:
system("tar -zxf /your/file.tar.gz")

Free C/C++ based zip/zip64 library?

After having false starts with poco's zip and minizip (both have issues, minizip can't decompress files larger than 2gb and poco zip corrupts any zip file larger than 2 gigs it compresses) I was wondering if there was anything else left?
So any suggestions for a C++ archive library that can handle zip AND zip64?
7-zip handles both, as far as I could tell from a quick glance at their source code. It's also LGPL, which should allow its use in a closed source app.
Well there is the all-around very proven ZLIB : http://zlib.net/

C/C++: Easily unzip to memory

I need to find a library that allows me to easily get a directory listing of all the files inside a ZIP archive and allows me to extract any given file inside the archive to memory (a buffer). Preferably, it should be a high-level library since my requirements aren't very complex (what I mentioned above is pretty much all I need).
Previously I tried PhysFS which has the behavior I need (easily access files inside an archive), but it's unsuitable because of other reasons (there are many archives and PhysFS would require me to mount all of them individually, which is not an option). Another library that kinda has the functionality I need is Chilkat, but it's shareware so I can't use it either.
Any other suggestions?
While .zip uses zlib http://zlib.net compression, it alone is not sufficient to get a directory listing from a .zip file.
You also need code that can read the .zip dictionary format. Check out Minizip http://www.winimage.com/zLibDll/minizip.html. It provides a code and simple zip/unzip command line executables.
edit 2 The code is entirely C (so is Zlib) -- the page has links to two c++ wrapper libs that both seem to be dead links.
How about zlib? http://zlib.net/ "A Massively Spiffy Yet Delicately Unobtrusive Compression Library (Also Free, Not to Mention Unencumbered by Patents)"

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

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.
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.
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.

What libraries should I use to manipulate archives from C++?

I want to manipulate .zip and .rar files from C++. What libraries should I use?
The zlib library comes with a sample showing how you can use it with .zip files (I think it's called "minizip" or something, though I haven't had much experience with it personally).
RAR is a bit difference, since it's basically proprietary. I don't know if there's any libraries that can do it.
zlib and minizip, yes. minizip was last updated in 2005. Some facts about version 1.01e:
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g, WinZip, InfoZip tools and compatible.
Multi volume ZipFile (span) are not supported.
Encryption compatible with pkzip 2.04g only supported
Old compressions used by old PKZip 1.x are not supported
boost::iostreams also is a good choice.
Open Source Ogre3d has implementation of zip decompressor, you can read it.
Codeka is correct in recommending zlib, but if you're on Windows, you might want to take a look at ZipUtils, which is zlib repackaged with a simpler interface and a few bells and whistles added.