summaryrefslogtreecommitdiffstats
path: root/quazip/JlCompress.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-08-05 03:29:50 +0200
committerPetr Mrázek <peterix@gmail.com>2013-08-05 03:29:50 +0200
commit183a7351456940d01f14a49112ddeb68ffc4693a (patch)
tree579aeb0b8670e634de4f083e54b3c826bf548ec9 /quazip/JlCompress.cpp
parent005a010ee6a67191ec24583780310fcf217ff30c (diff)
downloadMultiMC-183a7351456940d01f14a49112ddeb68ffc4693a.tar
MultiMC-183a7351456940d01f14a49112ddeb68ffc4693a.tar.gz
MultiMC-183a7351456940d01f14a49112ddeb68ffc4693a.tar.lz
MultiMC-183a7351456940d01f14a49112ddeb68ffc4693a.tar.xz
MultiMC-183a7351456940d01f14a49112ddeb68ffc4693a.zip
Runnable 1.6 instances!
Diffstat (limited to 'quazip/JlCompress.cpp')
-rw-r--r--quazip/JlCompress.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/quazip/JlCompress.cpp b/quazip/JlCompress.cpp
index 411645e1..69832140 100644
--- a/quazip/JlCompress.cpp
+++ b/quazip/JlCompress.cpp
@@ -384,6 +384,53 @@ QStringList JlCompress::extractFiles(QString fileCompressed, QStringList files,
return extracted;
}
+QStringList JlCompress::extractWithExceptions(QString fileCompressed, QString dir, QStringList exceptions)
+{
+ QuaZip zip(fileCompressed);
+ if(!zip.open(QuaZip::mdUnzip))
+ {
+ return QStringList();
+ }
+
+ QDir directory(dir);
+ QStringList extracted;
+ if (!zip.goToFirstFile())
+ {
+ return QStringList();
+ }
+ do
+ {
+ QString name = zip.getCurrentFileName();
+ bool ok = true;
+ for(auto str: exceptions)
+ {
+ if(name.startsWith(str))
+ {
+ ok = false;
+ break;
+ }
+ }
+ if(!ok)
+ continue;
+ QString absFilePath = directory.absoluteFilePath(name);
+ if (!JlCompress::extractFile(&zip, "", absFilePath))
+ {
+ JlCompress::removeFile(extracted);
+ return QStringList();
+ }
+ extracted.append(absFilePath);
+ } while (zip.goToNextFile());
+
+ zip.close();
+ if(zip.getZipError()!=0)
+ {
+ JlCompress::removeFile(extracted);
+ return QStringList();
+ }
+
+ return extracted;
+}
+
/**OK
* Estrae il file fileCompressed nella cartella dir.
* Se dir = "" allora il file viene estratto nella cartella corrente.