Runnable 1.6 instances!
This commit is contained in:
@ -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.
|
||||
|
@ -102,6 +102,15 @@ public:
|
||||
\return The list of the full paths of the files extracted, empty on failure.
|
||||
*/
|
||||
static QStringList extractDir(QString fileCompressed, QString dir = QString());
|
||||
/// Extract a whole archive, with a list of exceptions (prefixes to ignore).
|
||||
/**
|
||||
\param fileCompressed The name of the archive.
|
||||
\param dir The directory to extract to, the current directory if
|
||||
left empty.
|
||||
\param exceptions The list of exception prefixes
|
||||
\return The list of the full paths of the files extracted, empty on failure.
|
||||
*/
|
||||
static QStringList extractWithExceptions(QString fileCompressed, QString dir, QStringList exceptions);
|
||||
/// Get the file list.
|
||||
/**
|
||||
\return The list of the files in the archive, or, more precisely, the
|
||||
|
Reference in New Issue
Block a user