diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-08-25 01:32:42 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-08-25 01:32:42 +0200 |
commit | d884f849d60db44f05a6a6b22f4ffcf520900389 (patch) | |
tree | 22387a110c1e7dfeb5f68983b1f0ef0a13ba0aaa /depends/quazip/JlCompress.cpp | |
parent | e3b55067eb51ee82e72b41a1919406d768e00b89 (diff) | |
download | MultiMC-d884f849d60db44f05a6a6b22f4ffcf520900389.tar MultiMC-d884f849d60db44f05a6a6b22f4ffcf520900389.tar.gz MultiMC-d884f849d60db44f05a6a6b22f4ffcf520900389.tar.lz MultiMC-d884f849d60db44f05a6a6b22f4ffcf520900389.tar.xz MultiMC-d884f849d60db44f05a6a6b22f4ffcf520900389.zip |
All kinds of incremental improvements
Redone the instance action toolbar:
* Removed all the dead actions
* Change icon and Rename are now morphed into a header
* Added button for opening the config folder
Implemented support for loose files and folders as legacy jar mods
Added texture pack support
Diffstat (limited to 'depends/quazip/JlCompress.cpp')
-rw-r--r-- | depends/quazip/JlCompress.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/depends/quazip/JlCompress.cpp b/depends/quazip/JlCompress.cpp index 19bf6246..a6cf0eaf 100644 --- a/depends/quazip/JlCompress.cpp +++ b/depends/quazip/JlCompress.cpp @@ -75,17 +75,18 @@ bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) { * dunque gli errori di compressione di una sotto cartella sono gli stessi di questa * funzione. */ -bool JlCompress::compressSubDir(QuaZip* zip, QString dir, QString origDir, bool recursive) { +bool JlCompress::compressSubDir( QuaZip* parentZip, QString dir, QString parentDir, bool recursive, QSet<QString>& added ) +{ // zip: oggetto dove aggiungere il file // dir: cartella reale corrente // origDir: cartella reale originale // (path(dir)-path(origDir)) = path interno all'oggetto zip // Controllo l'apertura dello zip - if (!zip) return false; - if (zip->getMode()!=QuaZip::mdCreate && - zip->getMode()!=QuaZip::mdAppend && - zip->getMode()!=QuaZip::mdAdd) return false; + if (!parentZip ) return false; + if ( parentZip->getMode()!=QuaZip::mdCreate && + parentZip->getMode()!=QuaZip::mdAppend && + parentZip->getMode()!=QuaZip::mdAdd) return false; // Controllo la cartella QDir directory(dir); @@ -95,24 +96,28 @@ bool JlCompress::compressSubDir(QuaZip* zip, QString dir, QString origDir, bool if (recursive) { // Per ogni sotto cartella QFileInfoList files = directory.entryInfoList(QDir::AllDirs|QDir::NoDotAndDotDot); - Q_FOREACH (QFileInfo file, files) { + Q_FOREACH (QFileInfo file, files) + { // Comprimo la sotto cartella - if(!compressSubDir(zip,file.absoluteFilePath(),origDir,recursive)) return false; + if(!compressSubDir( parentZip,file.absoluteFilePath(),parentDir,recursive,added)) return false; } } // Per ogni file nella cartella QFileInfoList files = directory.entryInfoList(QDir::Files); - QDir origDirectory(origDir); - Q_FOREACH (QFileInfo file, files) { + QDir origDirectory( parentDir ); + Q_FOREACH (QFileInfo file, files) + { // Se non e un file o e il file compresso che sto creando - if(!file.isFile()||file.absoluteFilePath()==zip->getZipName()) continue; + if(!file.isFile()||file.absoluteFilePath()==parentZip->getZipName()) continue; // Creo il nome relativo da usare all'interno del file compresso QString filename = origDirectory.relativeFilePath(file.absoluteFilePath()); // Comprimo il file - if (!compressFile(zip,file.absoluteFilePath(),filename)) return false; + if (!compressFile( parentZip,file.absoluteFilePath(),filename)) + return false; + added.insert(filename); } return true; @@ -290,9 +295,10 @@ bool JlCompress::compressDir(QString fileCompressed, QString dir, bool recursive QFile::remove(fileCompressed); return false; } - + QSet<QString> added; // Aggiungo i file e le sotto cartelle - if (!compressSubDir(&zip,dir,dir,recursive)) { + if (!compressSubDir(&zip,dir,dir,recursive, added)) + { QFile::remove(fileCompressed); return false; } |