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
$ 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
To copy to clipboard, switch view to plain text mode
this code:
#include <QtCore>
#include <quazip/quazip.h>
int main(int argc, char **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;
}
#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;
}
To copy to clipboard, switch view to plain text mode
this result:
Opened
"a/"
"a/test1.txt"
"a/test2.txt"
"a/b/"
"a/b/test3.txt"
Opened
"a/"
"a/test1.txt"
"a/test2.txt"
"a/b/"
"a/b/test3.txt"
To copy to clipboard, switch view to plain text mode
So, if the file name ends with '/' create a directory, otherwise create a file and extract the data into it.
Bookmarks