From 183a7351456940d01f14a49112ddeb68ffc4693a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 5 Aug 2013 03:29:50 +0200 Subject: Runnable 1.6 instances! --- quazip/JlCompress.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'quazip/JlCompress.cpp') 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. -- cgit v1.2.3