View Full Version : unzip zip file contains files and folders with quazip

29th October 2013, 03:24
I want to extract a zip file contains files and folders using quazip in Qt but I have not find a good solution yet. I have searched and just found the way to extract zip file with files only, not contains folders. Does anyone can help me? Thanks a lot!

7th November 2013, 09:19
Ignore the spam above.

QuaZip gives you the full path along with the file name as you step through the archive. It is just a matter of recognising that and creating directories as you go.
This test file:

$ unzip -l test.zip
Archive: test.zip
Length Date Time Name
--------- ---------- ----- ----
0 11-07-2013 17:06 a/
0 11-07-2013 17:05 a/test1.txt
0 11-07-2013 17:05 a/test2.txt
0 11-07-2013 17:06 a/b/
0 11-07-2013 17:06 a/b/test3.txt
--------- -------
0 5 files

this code:

#include <QtCore>
#include <quazip/quazip.h>

int main(int argc, char **argv)
QCoreApplication app(argc, argv);

QuaZip zip("test.zip");
if (zip.open(QuaZip::mdUnzip)) {
qDebug() << "Opened";

for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) {
// do something
qDebug() << zip.getCurrentFileName();
if (zip.getZipError() == UNZ_OK) {
// ok, there was no error
return 0;

this result:


So, if the file name ends with '/' create a directory, otherwise create a file and extract the data into it.