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
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -16,6 +16,13 @@
|
||||
*/
|
||||
class QUAZIP_EXPORT JlCompress {
|
||||
private:
|
||||
/// Remove some files.
|
||||
/**
|
||||
\param listFile The list of files to remove.
|
||||
\return true if success, false otherwise.
|
||||
*/
|
||||
static bool removeFile(QStringList listFile);
|
||||
public:
|
||||
/// Compress a single file.
|
||||
/**
|
||||
\param zip Opened zip to compress the file to.
|
||||
@ -34,7 +41,7 @@ private:
|
||||
files.
|
||||
\return true if success, false otherwise.
|
||||
*/
|
||||
static bool compressSubDir(QuaZip* parentZip, QString dir, QString parentDir, bool recursive = true);
|
||||
static bool compressSubDir( QuaZip* parentZip, QString dir, QString parentDir, bool recursive, QSet< QString >& added );
|
||||
/// Extract a single file.
|
||||
/**
|
||||
\param zip The opened zip archive to extract from.
|
||||
@ -43,14 +50,7 @@ private:
|
||||
\return true if success, false otherwise.
|
||||
*/
|
||||
static bool extractFile(QuaZip* zip, QString fileName, QString fileDest);
|
||||
/// Remove some files.
|
||||
/**
|
||||
\param listFile The list of files to remove.
|
||||
\return true if success, false otherwise.
|
||||
*/
|
||||
static bool removeFile(QStringList listFile);
|
||||
|
||||
public:
|
||||
/// copy data from inFile to outFile
|
||||
static bool copyData(QIODevice &inFile, QIODevice &outFile);
|
||||
/// Compress a single file.
|
||||
|
Reference in New Issue
Block a user