I have many text files that are located in different directories -
dir1/.../textfiles/<various .txt files>
dir2/.../textfiles/<various .txt files>
and so on...
I need a c++ solution to compress and archive all these files present in different directories. I also need a way to search, decompress and open only a particular file in this archive.
One solution I can think of is to use system calls to create a tar archive.
I actually want a purely C++ based solution to this problem that is simple and fast and gives the desired result.
I searched a lot about this on the internet and found a few solutions like using Chilkat or libtar libraries but I do not intend to use them.
Another one that I found out is this.
Is there any simple C++ solution to this problem?
I have created ".tar" file and added multiple files in it while converting it to ".zip" i am facing problem.
I should create ".zip" for compress multiple files.
I need this in c++
code.BZ2 compression in C++ with bzlib.h I used this link to compress.
I tryed with http://www.winimage.com/zLibDll/minizip.html i feel its complicated.
please help me i am new to it Thank you so much in advance.
As far as I have used, Minizip is the best available open source to achieve this purpose. There are example classes, compress.c and uncompress.c which almost does everything related to zipping and unzipping
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/
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.
I'm working on a project using C++, Boost, and Qt. I understand how to compress single files and bytestreams using, for example, the qCompress() function in Qt.
How do I zip a directory of multiple files, including subdirectories? I am looking for a cross-platform (Mac, Win, Linux) solution; I'd prefer not to fire off a bunch of new processes.
Is there a standard way to combine bytestreams from multiple files into a zipped archive, or maybe there is a convenience function or method that would be available in the Boost iostream library?
Many thanks for the assistance.
Update: The QuaZip library looks really great. There is an example in the download package (in the "tests" dir) that shows very clearly how to zip up a directory of files.
Update 2: After completing this task on my Linux build environment, I discovered that QuaZip doesn't work at all with the Visual Studio compiler. It may be possible to tackle all those compiler errors, but a word of caution to anyone looking down this path.
I have found the following two libraries:
ZipIOS++. Seems to be "pure" C++. They don't list Windows explicitly as a supported platform. So i think you should try your luck yourself.
QuaZIP. Based on Qt4. Actually looks nice. They list Windows explicitly (Using mingw). Apparently, it is a C++ wrapper for [this] library.
Ah, and of course, i have ripped those sites from this Qt Mailinglist question about Zipping/Unzipping of directories :)
Just for the record...
Today, I needed to do something very similar in Visual C++. (Though wanted to maintain the possibility to compile the project on other platforms; however preferred not to adopt Qt just for this purpose.)
Ended up using the Minizip library. It is written in plain C, but devising a simple C++ wrapper around it was a breeze, and the end result works great, at least for my purposes.
I have built a wrapper around minizip adding some features that I needed and making it nicer to use it. Is does use the latest c++11 and is developed using Visual Studio 2013, so it should work out-of-the-box for you.
There's a full description here: https://github.com/sebastiandev/zipper
you can zip entire folders, streams, vectors, etc. Also a nice feature is doing everything entirely in memory.
Poco::Zip is also a choice, it has clearly documentation and some code for demo.
Poco::Zip Document
system("zip myarchive.zip *");
I tried QuaZIP 0.4.3 on Windows with VisualStudio 2010 -- there are still issues but can be resolved easily.
To build with VS:
Use CMake to configure and generate VS solution for QuaZIP.
Open soltion with VS and build -- you'll first notice that it can't find 'zlib.h'.
Open preferences for quazip project and add path to Qt's copy of Zlib to C/C++->General->Additional Include Directories: $(QTDIR)/src/3rdparty/zlib.
Rebuild again and you'll get lots of warnings and one error C2491: dllimport static issue on QuaZipFile::staticMetaObject.
This is because QuaZipFile is declared like "class QUAZIP_EXPORT QuaZipFile" and QUAZIP_EXPORT needs to resolve to Q_DECL_EXPORT for dll and to Q_DECL_IMPORT for application, based on whether QUAZIP_BUILD is defined or not. When building QuaZIP QUAZIP_BUILD should be defined but isn't -- configuration process defines in error completely useless "quazip_EXPORTS" instead.
To fix, just remove "quazip_EXPORTS" from all build configurations and add QUAZIP_BUILD instead -- QuaZIP will now build fine.