diff options
| author | Petr Mrázek <peterix@gmail.com> | 2015-10-05 01:47:27 +0200 |
|---|---|---|
| committer | Petr Mrázek <peterix@gmail.com> | 2015-10-05 01:47:27 +0200 |
| commit | f93f867c3da084c6d6c5e3ed23896609cff0e692 (patch) | |
| tree | 3234c54d9aefb5566afc0c8ff52874e20ab35304 | |
| parent | 7459eb627c97d27ef6e12cdededa48e1ff03d533 (diff) | |
| download | PrismLauncher-f93f867c3da084c6d6c5e3ed23896609cff0e692.tar.gz PrismLauncher-f93f867c3da084c6d6c5e3ed23896609cff0e692.tar.bz2 PrismLauncher-f93f867c3da084c6d6c5e3ed23896609cff0e692.zip | |
NOISSUE dissolve util library
80 files changed, 770 insertions, 869 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c896de08..f432f851 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,6 @@ add_subdirectory(depends/libnbtplusplus) ######## MultiMC Libs ######## -add_subdirectory(depends/util) # various utility functions add_subdirectory(depends/LogicalGui) # GUI -> Logic connection add_subdirectory(depends/iconfix) # fork of Qt's QIcon loader diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index fdb27607..d9c37a45 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -348,7 +348,7 @@ qt5_add_resources(MULTIMC_RESOURCES ${MULTIMC_QRCS}) # Add executable add_executable(MultiMC MACOSX_BUNDLE WIN32 ${MULTIMC_SOURCES} ${MULTIMC_UI} ${MULTIMC_RESOURCES} ${MULTIMC_RCS}) -target_link_libraries(MultiMC MultiMC_logic xz-embedded unpack200 iconfix MultiMC_util ${QUAZIP_LIBRARIES} hoedown rainbow) +target_link_libraries(MultiMC MultiMC_logic xz-embedded unpack200 iconfix ${QUAZIP_LIBRARIES} hoedown rainbow) if(APPLE) find_library(OSX_CORE_FOUNDATION CoreFoundation) diff --git a/application/InstancePageProvider.h b/application/InstancePageProvider.h index c3ae17c1..1b283896 100644 --- a/application/InstancePageProvider.h +++ b/application/InstancePageProvider.h @@ -1,6 +1,7 @@ #pragma once #include "minecraft/OneSixInstance.h" #include "minecraft/LegacyInstance.h" +#include <FileSystem.h> #include "pages/BasePage.h" #include "pages/VersionPage.h" #include "pages/ModFolderPage.h" @@ -13,7 +14,6 @@ #include "pages/BasePageProvider.h" #include "pages/LegacyJarModPage.h" #include "pages/WorldListPage.h" -#include <pathutils.h> class InstancePageProvider : public QObject, public BasePageProvider @@ -41,7 +41,7 @@ public: values.append(new TexturePackPage(onesix.get())); values.append(new NotesPage(onesix.get())); values.append(new WorldListPage(onesix.get(), onesix->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); - values.append(new ScreenshotsPage(PathCombine(onesix->minecraftRoot(), "screenshots"))); + values.append(new ScreenshotsPage(FS::PathCombine(onesix->minecraftRoot(), "screenshots"))); values.append(new InstanceSettingsPage(onesix.get())); } std::shared_ptr<LegacyInstance> legacy = std::dynamic_pointer_cast<LegacyInstance>(inst); @@ -57,7 +57,7 @@ public: values.append(new TexturePackPage(legacy.get())); values.append(new NotesPage(legacy.get())); values.append(new WorldListPage(legacy.get(), legacy->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); - values.append(new ScreenshotsPage(PathCombine(legacy->minecraftRoot(), "screenshots"))); + values.append(new ScreenshotsPage(FS::PathCombine(legacy->minecraftRoot(), "screenshots"))); values.append(new InstanceSettingsPage(legacy.get())); } auto logMatcher = inst->getLogFileMatcher(); diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 1562efc5..71888870 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -331,10 +331,6 @@ namespace Ui { #include <MMCZip.h> -#include "osutils.h" -#include "userutils.h" -#include "pathutils.h" - #include "groupview/GroupView.h" #include "groupview/InstanceDelegate.h" #include "InstanceProxyModel.h" @@ -972,8 +968,8 @@ void MainWindow::downloadUpdates(GoUpdate::Status status) ProgressDialog updateDlg(this); status.rootPath = MMC->rootPath; - auto dlPath = PathCombine(MMC->root(), "update", "XXXXXX"); - if(!ensureFilePathExists(dlPath)) + auto dlPath = FS::PathCombine(MMC->root(), "update", "XXXXXX"); + if(!FS::ensureFilePathExists(dlPath)) { CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show(); } @@ -1053,8 +1049,8 @@ InstancePtr MainWindow::instanceFromZipPack(QString instName, QString instGroup, InstancePtr newInstance; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); - QString instDirName = DirNameFromString(instName, instancesDir); - QString instDir = PathCombine(instancesDir, instDirName); + QString instDirName = FS::DirNameFromString(instName, instancesDir); + QString instDir = FS::PathCombine(instancesDir, instDirName); QString archivePath; if (url.isLocalFile()) @@ -1094,7 +1090,7 @@ InstancePtr MainWindow::instanceFromZipPack(QString instName, QString instGroup, CustomMessageBox::selectable(this, tr("Error"), tr("Archive does not contain instance.cfg"))->show(); return nullptr; } - if (!copyPath(instanceCfgFile.absoluteDir().absolutePath(), instDir)) + if (!FS::copyPath(instanceCfgFile.absoluteDir().absolutePath(), instDir)) { CustomMessageBox::selectable(this, tr("Error"), tr("Unable to copy instance"))->show(); return nullptr; @@ -1124,7 +1120,7 @@ InstancePtr MainWindow::instanceFromZipPack(QString instName, QString instGroup, else { instIcon = newInstance->iconKey(); - auto importIconPath = PathCombine(newInstance->instanceRoot(), instIcon + ".png"); + auto importIconPath = FS::PathCombine(newInstance->instanceRoot(), instIcon + ".png"); if (QFile::exists(importIconPath)) { // import icon @@ -1153,8 +1149,8 @@ InstancePtr MainWindow::instanceFromVersion(QString instName, QString instGroup, InstancePtr newInstance; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); - QString instDirName = DirNameFromString(instName, instancesDir); - QString instDir = PathCombine(instancesDir, instDirName); + QString instDirName = FS::DirNameFromString(instName, instancesDir); + QString instDir = FS::PathCombine(instancesDir, instDirName); auto error = MMC->instances()->createInstance(newInstance, version, instDir); QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName); switch (error) @@ -1257,11 +1253,12 @@ void MainWindow::on_actionCopyInstance_triggered() return; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); - QString instDirName = DirNameFromString(copyInstDlg.instName(), instancesDir); - QString instDir = PathCombine(instancesDir, instDirName); + QString instDirName = FS::DirNameFromString(copyInstDlg.instName(), instancesDir); + QString instDir = FS::PathCombine(instancesDir, instDirName); + bool copySaves = copyInstDlg.shouldCopySaves(); InstancePtr newInstance; - auto error = MMC->instances()->copyInstance(newInstance, m_selectedInstance, instDir); + auto error = MMC->instances()->copyInstance(newInstance, m_selectedInstance, instDir, copySaves); QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName); switch (error) @@ -1359,7 +1356,7 @@ void MainWindow::on_actionChangeInstGroup_triggered() void MainWindow::on_actionViewInstanceFolder_triggered() { QString str = MMC->settings()->get("InstanceDir").toString(); - openDirInDefaultProgram(str); + FS::openDirInDefaultProgram(str); } void MainWindow::on_actionRefresh_triggered() @@ -1369,7 +1366,7 @@ void MainWindow::on_actionRefresh_triggered() void MainWindow::on_actionViewCentralModsFolder_triggered() { - openDirInDefaultProgram(MMC->settings()->get("CentralModsDir").toString(), true); + FS::openDirInDefaultProgram(MMC->settings()->get("CentralModsDir").toString(), true); } void MainWindow::on_actionConfig_Folder_triggered() @@ -1377,7 +1374,7 @@ void MainWindow::on_actionConfig_Folder_triggered() if (m_selectedInstance) { QString str = m_selectedInstance->instanceConfigFolder(); - openDirInDefaultProgram(QDir(str).absolutePath()); + FS::openDirInDefaultProgram(QDir(str).absolutePath()); } } @@ -1509,7 +1506,7 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered() if (m_selectedInstance) { QString str = m_selectedInstance->instanceRoot(); - openDirInDefaultProgram(QDir(str).absolutePath()); + FS::openDirInDefaultProgram(QDir(str).absolutePath()); } } @@ -1677,7 +1674,7 @@ void MainWindow::checkSetDefaultJava() break; } QString currentJavaPath = MMC->settings()->get("JavaPath").toString(); - QString actualPath = ResolveExecutable(currentJavaPath); + QString actualPath = FS::ResolveExecutable(currentJavaPath); if (currentJavaPath.isNull()) { askForJava = true; @@ -1738,7 +1735,7 @@ void MainWindow::checkSetDefaultJava() void MainWindow::checkInstancePathForProblems() { QString instanceFolder = MMC->settings()->get("InstanceDir").toString(); - if (checkProblemticPathJava(QDir(instanceFolder))) + if (FS::checkProblemticPathJava(QDir(instanceFolder))) { QMessageBox warning(this); warning.setText(tr( diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 612ba342..5584de1f 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -41,8 +41,6 @@ #include "tools/JVisualVM.h" #include "tools/MCEditTool.h" -#include "pathutils.h" -#include "cmdutils.h" #include <xdgicon.h> #include "settings/INISettingsObject.h" #include "settings/Setting.h" @@ -54,7 +52,10 @@ #include "ftb/FTBPlugin.h" -using namespace Util::Commandline; +#include <Commandline.h> +#include <FileSystem.h> + +using namespace Commandline; MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, argv) { @@ -142,7 +143,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar launchId = args["launch"].toString(); - if (!ensureFolderPathExists(dataPath) || !QDir::setCurrent(dataPath)) + if (!FS::ensureFolderPathExists(dataPath) || !QDir::setCurrent(dataPath)) { // BAD STUFF. WHAT DO? initLogger(); @@ -159,7 +160,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar else { #ifdef Q_OS_LINUX - QDir foo(PathCombine(binPath, "..")); + QDir foo(FS::PathCombine(binPath, "..")); rootPath = foo.absolutePath(); #elif defined(Q_OS_WIN32) rootPath = binPath; @@ -171,12 +172,12 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar // static data paths... mostly just for translations #ifdef Q_OS_LINUX - QDir foo(PathCombine(binPath, "..")); + QDir foo(FS::PathCombine(binPath, "..")); staticDataPath = foo.absolutePath(); #elif defined(Q_OS_WIN32) staticDataPath = binPath; #elif defined(Q_OS_MAC) - QDir foo(PathCombine(rootPath, "Contents/Resources")); + QDir foo(FS::PathCombine(rootPath, "Contents/Resources")); staticDataPath = foo.absolutePath(); #endif @@ -220,7 +221,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar // and rememer that we have to show him a dialog when the gui starts (if it does so) QString instDir = m_settings->get("InstanceDir").toString(); qDebug() << "Instance path : " << instDir; - if (checkProblemticPathJava(QDir(instDir))) + if (FS::checkProblemticPathJava(QDir(instDir))) { qWarning() << "Your instance path contains \'!\' and this is known to cause java problems"; @@ -671,26 +672,26 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi bool started = false; qDebug() << "Installing updates."; -#ifdef WINDOWS +#ifdef Q_OS_WIN QString finishCmd = applicationFilePath(); -#elif LINUX - QString finishCmd = PathCombine(root(), "MultiMC"); -#elif OSX +#elif defined Q_OS_LINUX + QString finishCmd = FS::PathCombine(root(), "MultiMC"); +#elif defined Q_OS_MAC QString finishCmd = applicationFilePath(); #else #error Unsupported operating system. #endif - QString backupPath = PathCombine(root(), "update", "backup"); + QString backupPath = FS::PathCombine(root(), "update", "backup"); QDir origin(root()); // clean up the backup folder. it should be empty before we start - if(!deletePath(backupPath)) + if(!FS::deletePath(backupPath)) { qWarning() << "couldn't remove previous backup folder" << backupPath; } // and it should exist. - if(!ensureFolderPathExists(backupPath)) + if(!FS::ensureFolderPathExists(backupPath)) { qWarning() << "couldn't create folder" << backupPath; return; @@ -726,7 +727,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi // replace = move original out to backup, if it exists, move the new file in its place case GoUpdate::Operation::OP_REPLACE: { - QFileInfo replaced (PathCombine(root(), op.dest)); + QFileInfo replaced (FS::PathCombine(root(), op.dest)); #ifdef Q_OS_WIN32 if(QSysInfo::windowsVersion() < QSysInfo::WV_VISTA) { @@ -735,7 +736,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi QDir rootDir(root()); exeOrigin = rootDir.relativeFilePath(op.file); exePath = rootDir.relativeFilePath(op.dest); - exeBackup = rootDir.relativeFilePath(PathCombine(backupPath, replaced.fileName())); + exeBackup = rootDir.relativeFilePath(FS::PathCombine(backupPath, replaced.fileName())); useXPHack = true; continue; } @@ -745,7 +746,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi { QString backupName = op.dest; backupName.replace('/', '_'); - QString backupFilePath = PathCombine(backupPath, backupName); + QString backupFilePath = FS::PathCombine(backupPath, backupName); if(!QFile::rename(replaced.absoluteFilePath(), backupFilePath)) { qWarning() << "Couldn't move:" << replaced.absoluteFilePath() << "to" << backupFilePath; @@ -759,7 +760,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi backups.append(be); } // make sure the folder we are putting this into exists - if(!ensureFilePathExists(replaced.absoluteFilePath())) + if(!FS::ensureFilePathExists(replaced.absoluteFilePath())) { qWarning() << "REPLACE: Couldn't create folder:" << replaced.absoluteFilePath(); failedOperationType = Replace; @@ -780,12 +781,12 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi // delete = move original to backup case GoUpdate::Operation::OP_DELETE: { - QString origFilePath = PathCombine(root(), op.file); + QString origFilePath = FS::PathCombine(root(), op.file); if(QFile::exists(origFilePath)) { QString backupName = op.file; backupName.replace('/', '_'); - QString trashFilePath = PathCombine(backupPath, backupName); + QString trashFilePath = FS::PathCombine(backupPath, backupName); if(!QFile::rename(origFilePath, trashFilePath)) { @@ -825,7 +826,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi out << "fso.MoveFile \"" << nativeOriginPath << "\", \"" << nativePath << "\"\n"; out << "shell.Run \"" << nativePath << "\"\n"; - QString scriptPath = PathCombine(root(), "update", "update.vbs"); + QString scriptPath = FS::PathCombine(root(), "update", "update.vbs"); // we save it QFile scriptFile(scriptPath); diff --git a/application/VersionProxyModel.cpp b/application/VersionProxyModel.cpp index 4db5cbd0..70894592 100644 --- a/application/VersionProxyModel.cpp +++ b/ |
