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 /logic/LegacyUpdate.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 'logic/LegacyUpdate.cpp')
-rw-r--r-- | logic/LegacyUpdate.cpp | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp index 9644cb80..0dc8ee72 100644 --- a/logic/LegacyUpdate.cpp +++ b/logic/LegacyUpdate.cpp @@ -271,7 +271,15 @@ bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >& { return false; } - if(!zipOutFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileInsideMod.getActualFileName()))) + /* + QuaZipFileInfo old_info; + fileInsideMod.getFileInfo(&old_info); + */ + QuaZipNewInfo info_out(fileInsideMod.getActualFileName()); + /* + info_out.externalAttr = old_info.externalAttr; + */ + if(!zipOutFile.open(QIODevice::WriteOnly, info_out)) { fileInsideMod.close(); return false; @@ -369,31 +377,32 @@ void LegacyUpdate::ModTheJar() } else if (mod.type() == Mod::MOD_SINGLEFILE) { - zipOut.close(); - QFile::remove(runnableJar.filePath()); - emitFailed("Loose files are NOT supported as jar mods."); - return; - /* - wxFileName destFileName = modFileName; - destFileName.MakeRelativeTo(m_inst->GetInstModsDir().GetFullPath()); - wxString destFile = destFileName.GetFullPath(); - - if (addedFiles.count(destFile) == 0) + auto filename = mod.filename(); + if(!JlCompress::compressFile(&zipOut, filename.absoluteFilePath(), filename.fileName())) { - wxFFileInputStream input(modFileName.GetFullPath()); - zipOut.PutNextEntry(destFile); - zipOut.Write(input); - - addedFiles.insert(destFile); + zipOut.close(); + QFile::remove(runnableJar.filePath()); + emitFailed("Failed to add " + filename.fileName() + " to the jar"); + return; } - */ + addedFiles.insert(filename.fileName()); + qDebug() << "Adding file " << filename.fileName() << " from " << filename.absoluteFilePath(); } else if (mod.type() == Mod::MOD_FOLDER) { - zipOut.close(); - QFile::remove(runnableJar.filePath()); - emitFailed("Folders are NOT supported as jar mods."); - return; + auto filename = mod.filename(); + QString what_to_zip = filename.absoluteFilePath(); + QDir dir(what_to_zip); + dir.cdUp(); + QString parent_dir = dir.absolutePath(); + if(!JlCompress::compressSubDir(&zipOut, what_to_zip, parent_dir, true, addedFiles)) + { + zipOut.close(); + QFile::remove(runnableJar.filePath()); + emitFailed("Failed to add " + filename.fileName() + " to the jar"); + return; + } + qDebug() << "Adding folder " << filename.fileName() << " from " << filename.absoluteFilePath(); } } |