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 /logic/minecraft | |
parent | 7459eb627c97d27ef6e12cdededa48e1ff03d533 (diff) | |
download | MultiMC-f93f867c3da084c6d6c5e3ed23896609cff0e692.tar MultiMC-f93f867c3da084c6d6c5e3ed23896609cff0e692.tar.gz MultiMC-f93f867c3da084c6d6c5e3ed23896609cff0e692.tar.lz MultiMC-f93f867c3da084c6d6c5e3ed23896609cff0e692.tar.xz MultiMC-f93f867c3da084c6d6c5e3ed23896609cff0e692.zip |
NOISSUE dissolve util library
Diffstat (limited to 'logic/minecraft')
-rw-r--r-- | logic/minecraft/AssetsUtils.cpp | 17 | ||||
-rw-r--r-- | logic/minecraft/LegacyInstance.cpp | 29 | ||||
-rw-r--r-- | logic/minecraft/LegacyUpdate.cpp | 24 | ||||
-rw-r--r-- | logic/minecraft/MinecraftInstance.cpp | 8 | ||||
-rw-r--r-- | logic/minecraft/MinecraftProfile.cpp | 1 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersionList.cpp | 7 | ||||
-rw-r--r-- | logic/minecraft/Mod.cpp | 6 | ||||
-rw-r--r-- | logic/minecraft/ModList.cpp | 10 | ||||
-rw-r--r-- | logic/minecraft/OneSixInstance.cpp | 24 | ||||
-rw-r--r-- | logic/minecraft/OneSixProfileStrategy.cpp | 36 | ||||
-rw-r--r-- | logic/minecraft/OneSixUpdate.cpp | 10 | ||||
-rw-r--r-- | logic/minecraft/RawLibrary.cpp | 4 | ||||
-rw-r--r-- | logic/minecraft/VersionFile.cpp | 6 | ||||
-rw-r--r-- | logic/minecraft/World.cpp | 12 | ||||
-rw-r--r-- | logic/minecraft/WorldList.cpp | 4 |
15 files changed, 97 insertions, 101 deletions
diff --git a/logic/minecraft/AssetsUtils.cpp b/logic/minecraft/AssetsUtils.cpp index 63179228..b3589cb8 100644 --- a/logic/minecraft/AssetsUtils.cpp +++ b/logic/minecraft/AssetsUtils.cpp @@ -23,7 +23,7 @@ #include <QDebug> #include "AssetsUtils.h" -#include <pathutils.h> +#include <FileSystem.h> namespace AssetsUtils { @@ -125,13 +125,13 @@ bool loadAssetsIndexJson(QString path, AssetsIndex *index) QDir reconstructAssets(QString assetsId) { QDir assetsDir = QDir("assets/"); - QDir indexDir = QDir(PathCombine(assetsDir.path(), "indexes")); - QDir objectDir = QDir(PathCombine(assetsDir.path(), "objects")); - QDir virtualDir = QDir(PathCombine(assetsDir.path(), "virtual")); + QDir indexDir = QDir(FS::PathCombine(assetsDir.path(), "indexes")); + QDir objectDir = QDir(FS::PathCombine(assetsDir.path(), "objects")); + QDir virtualDir = QDir(FS::PathCombine(assetsDir.path(), "virtual")); - QString indexPath = PathCombine(indexDir.path(), assetsId + ".json"); + QString indexPath = FS::PathCombine(indexDir.path(), assetsId + ".json"); QFile indexFile(indexPath); - QDir virtualRoot(PathCombine(virtualDir.path(), assetsId)); + QDir virtualRoot(FS::PathCombine(virtualDir.path(), assetsId)); if (!indexFile.exists()) { @@ -152,13 +152,12 @@ QDir reconstructAssets(QString assetsId) for (QString map : index.objects.keys()) { AssetObject asset_object = index.objects.value(map); - QString target_path = PathCombine(virtualRoot.path(), map); + QString target_path = FS::PathCombine(virtualRoot.path(), map); QFile target(target_path); QString tlk = asset_object.hash.left(2); - QString original_path = - PathCombine(PathCombine(objectDir.path(), tlk), asset_object.hash); + QString original_path = FS::PathCombine(objectDir.path(), tlk, asset_object.hash); QFile original(original_path); if (!original.exists()) continue; diff --git a/logic/minecraft/LegacyInstance.cpp b/logic/minecraft/LegacyInstance.cpp index 342a6f2d..227fd601 100644 --- a/logic/minecraft/LegacyInstance.cpp +++ b/logic/minecraft/LegacyInstance.cpp @@ -17,8 +17,6 @@ #include <QDir> #include <QImage> #include <settings/Setting.h> -#include <pathutils.h> -#include <cmdutils.h> #include "LegacyInstance.h" @@ -35,6 +33,7 @@ #include "minecraft/ModList.h" #include "minecraft/WorldList.h" #include <MMCZip.h> +#include <FileSystem.h> LegacyInstance::LegacyInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) : MinecraftInstance(globalSettings, settings, rootDir) @@ -109,7 +108,7 @@ std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr sess QString launchScript; QIcon icon = ENV.icons()->getIcon(iconKey()); auto pixmap = icon.pixmap(128, 128); - pixmap.save(PathCombine(minecraftRoot(), "icon.png"), "PNG"); + pixmap.save(FS::PathCombine(minecraftRoot(), "icon.png"), "PNG"); // create the launch script { @@ -331,56 +330,56 @@ std::shared_ptr<WorldList> LegacyInstance::worldList() const QString LegacyInstance::jarModsDir() const { - return PathCombine(instanceRoot(), "instMods"); + return FS::PathCombine(instanceRoot(), "instMods"); } QString LegacyInstance::binDir() const { - return PathCombine(minecraftRoot(), "bin"); + return FS::PathCombine(minecraftRoot(), "bin"); } QString LegacyInstance::libDir() const { - return PathCombine(minecraftRoot(), "lib"); + return FS::PathCombine(minecraftRoot(), "lib"); } QString LegacyInstance::savesDir() const { - return PathCombine(minecraftRoot(), "saves"); + return FS::PathCombine(minecraftRoot(), "saves"); } QString LegacyInstance::loaderModsDir() const { - return PathCombine(minecraftRoot(), "mods"); + return FS::PathCombine(minecraftRoot(), "mods"); } QString LegacyInstance::coreModsDir() const { - return PathCombine(minecraftRoot(), "coremods"); + return FS::PathCombine(minecraftRoot(), "coremods"); } QString LegacyInstance::resourceDir() const { - return PathCombine(minecraftRoot(), "resources"); + return FS::PathCombine(minecraftRoot(), "resources"); } QString LegacyInstance::texturePacksDir() const { - return PathCombine(minecraftRoot(), "texturepacks"); + return FS::PathCombine(minecraftRoot(), "texturepacks"); } QString LegacyInstance::runnableJar() const { - return PathCombine(binDir(), "minecraft.jar"); + return FS::PathCombine(binDir(), "minecraft.jar"); } QString LegacyInstance::modListFile() const { - return PathCombine(instanceRoot(), "modlist"); + return FS::PathCombine(instanceRoot(), "modlist"); } QString LegacyInstance::instanceConfigFolder() const { - return PathCombine(minecraftRoot(), "config"); + return FS::PathCombine(minecraftRoot(), "config"); } bool LegacyInstance::shouldRebuild() const @@ -442,7 +441,7 @@ QString LegacyInstance::defaultBaseJar() const QString LegacyInstance::defaultCustomBaseJar() const { - return PathCombine(binDir(), "mcbackup.jar"); + return FS::PathCombine(binDir(), "mcbackup.jar"); } QString LegacyInstance::lwjglFolder() const diff --git a/logic/minecraft/LegacyUpdate.cpp b/logic/minecraft/LegacyUpdate.cpp index c48984c4..2fd8e3cb 100644 --- a/logic/minecraft/LegacyUpdate.cpp +++ b/logic/minecraft/LegacyUpdate.cpp @@ -14,7 +14,6 @@ */ #include <QStringList> -#include <pathutils.h> #include <quazip.h> #include <quazipfile.h> #include <QDebug> @@ -30,6 +29,7 @@ #include "minecraft/MinecraftVersionList.h" #include "minecraft/ModList.h" #include "minecraft/LegacyInstance.h" +#include <FileSystem.h> LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : Task(parent), m_inst(inst) { @@ -92,7 +92,7 @@ void LegacyUpdate::fmllibsStart() // now check the lib folder inside the instance for files. for (auto &lib : libList) { - QFileInfo libInfo(PathCombine(inst->libDir(), lib.filename)); + QFileInfo libInfo(FS::PathCombine(inst->libDir(), lib.filename)); if (libInfo.exists()) continue; fmlLibsToProcess.append(lib); @@ -137,13 +137,13 @@ void LegacyUpdate::fmllibsFinished() { progress(index, fmlLibsToProcess.size()); auto entry = metacache->resolveEntry("fmllibs", lib.filename); - auto path = PathCombine(inst->libDir(), lib.filename); - if(!ensureFilePathExists(path)) + auto path = FS::PathCombine(inst->libDir(), lib.filename); + if(!FS::ensureFilePathExists(path)) { emitFailed(tr("Failed creating FML library folder inside the instance.")); return; } - if (!QFile::copy(entry->getFullPath(), PathCombine(inst->libDir(), lib.filename))) + if (!QFile::copy(entry->getFullPath(), FS::PathCombine(inst->libDir(), lib.filename))) { emitFailed(tr("Failed copying Forge/FML library: %1.").arg(lib.filename)); return; @@ -166,11 +166,11 @@ void LegacyUpdate::lwjglStart() LegacyInstance *inst = (LegacyInstance *)m_inst; lwjglVersion = inst->lwjglVersion(); - lwjglTargetPath = PathCombine(inst->lwjglFolder(), lwjglVersion); - lwjglNativesPath = PathCombine(lwjglTargetPath, "natives"); + lwjglTargetPath = FS::PathCombine(inst->lwjglFolder(), lwjglVersion); + lwjglNativesPath = FS::PathCombine(lwjglTargetPath, "natives"); // if the 'done' file exists, we don't have to download this again - QFileInfo doneFile(PathCombine(lwjglTargetPath, "done")); + QFileInfo doneFile(FS::PathCombine(lwjglTargetPath, "done")); if (doneFile.exists()) { jarStart(); @@ -256,7 +256,7 @@ void LegacyUpdate::extractLwjgl() { // make sure the directories are there - bool success = ensureFolderPathExists(lwjglNativesPath); + bool success = FS::ensureFolderPathExists(lwjglNativesPath); if (!success) { @@ -295,7 +295,7 @@ void LegacyUpdate::extractLwjgl() { if (name.endsWith(jarNames[i])) { - destFileName = PathCombine(lwjglTargetPath, jarNames[i]); + destFileName = FS::PathCombine(lwjglTargetPath, jarNames[i]); } } // Not found? look for the natives @@ -318,7 +318,7 @@ void LegacyUpdate::extractLwjgl() name = name.mid(lastSlash + 1); else if (lastBackSlash != -1) name = name.mid(lastBackSlash + 1); - destFileName = PathCombine(lwjglNativesPath, name); + destFileName = FS::PathCombine(lwjglNativesPath, name); } } // Now if destFileName is still empty, go to the next file. @@ -334,7 +334,7 @@ void LegacyUpdate::extractLwjgl() } zip.close(); m_reply.reset(); - QFile doneFile(PathCombine(lwjglTargetPath, "done")); + QFile doneFile(FS::PathCombine(lwjglTargetPath, "done")); doneFile.open(QIODevice::WriteOnly); doneFile.write("done."); doneFile.close(); diff --git a/logic/minecraft/MinecraftInstance.cpp b/logic/minecraft/MinecraftInstance.cpp index 8fd65d50..0dab4dfe 100644 --- a/logic/minecraft/MinecraftInstance.cpp +++ b/logic/minecraft/MinecraftInstance.cpp @@ -1,12 +1,12 @@ #include "MinecraftInstance.h" #include <settings/Setting.h> #include "settings/SettingsObject.h" -#include <pathutils.h> #include "Env.h" #include "minecraft/MinecraftVersionList.h" #include <MMCStrings.h> #include <pathmatcher/RegexpMatcher.h> #include <pathmatcher/MultiMatcher.h> +#include <FileSystem.h> #define IBUS "@im=ibus" @@ -67,8 +67,8 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO QString MinecraftInstance::minecraftRoot() const { - QFileInfo mcDir(PathCombine(instanceRoot(), "minecraft")); - QFileInfo dotMCDir(PathCombine(instanceRoot(), ".minecraft")); + QFileInfo mcDir(FS::PathCombine(instanceRoot(), "minecraft")); + QFileInfo dotMCDir(FS::PathCombine(instanceRoot(), ".minecraft")); if (dotMCDir.exists() && !mcDir.exists()) return dotMCDir.filePath(); @@ -115,7 +115,7 @@ QStringList MinecraftInstance::javaArguments() const } args << "-Duser.language=en"; - args << "-jar" << PathCombine(QCoreApplication::applicationDirPath(), "jars", "NewLaunch.jar"); + args << "-jar" << FS::PathCombine(QCoreApplication::applicationDirPath(), "jars", "NewLaunch.jar"); return args; } diff --git a/logic/minecraft/MinecraftProfile.cpp b/logic/minecraft/MinecraftProfile.cpp index efeb254b..4f33920b 100644 --- a/logic/minecraft/MinecraftProfile.cpp +++ b/logic/minecraft/MinecraftProfile.cpp @@ -18,7 +18,6 @@ #include <QJsonDocument> #include <QJsonArray> #include <QDebug> -#include <pathutils.h> #include "minecraft/MinecraftProfile.h" #include "ProfileUtils.h" diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp index afa7c4c5..8d52c23b 100644 --- a/logic/minecraft/MinecraftVersionList.cpp +++ b/logic/minecraft/MinecraftVersionList.cpp @@ -27,8 +27,7 @@ #include "ParseUtils.h" #include "ProfileUtils.h" #include "VersionFilterData.h" - -#include <pathutils.h> +#include <FileSystem.h> static const char * localVersionCache = "versions/versions.dat"; @@ -548,7 +547,7 @@ void MCVListVersionUpdateTask::json_downloaded() auto doc = file->toJson(false); auto newdata = doc.toBinaryData(); QString targetPath = "versions/" + versionToUpdate + "/" + versionToUpdate + ".dat"; - ensureFilePathExists(targetPath); + FS::ensureFilePathExists(targetPath); QSaveFile vfile1(targetPath); if (!vfile1.open(QIODevice::Truncate | QIODevice::WriteOnly)) { @@ -582,7 +581,7 @@ std::shared_ptr<Task> MinecraftVersionList::createUpdateTask(QString version) void MinecraftVersionList::saveCachedList() { // FIXME: throw. - if (!ensureFilePathExists(localVersionCache)) + if (!FS::ensureFilePathExists(localVersionCache)) return; QSaveFile tfile(localVersionCache); if (!tfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) diff --git a/logic/minecraft/Mod.cpp b/logic/minecraft/Mod.cpp index f8eb4faf..879ca195 100644 --- a/logic/minecraft/Mod.cpp +++ b/logic/minecraft/Mod.cpp @@ -23,8 +23,8 @@ #include <quazipfile.h> #include "Mod.h" -#include <pathutils.h> #include "settings/INIFile.h" +#include <FileSystem.h> #include <QDebug> Mod::Mod(const QFileInfo &file) @@ -113,7 +113,7 @@ void Mod::repath(const QFileInfo &file) } else if (m_type == MOD_FOLDER) { - QFileInfo mcmod_info(PathCombine(m_file.filePath(), "mcmod.info")); + QFileInfo mcmod_info(FS::PathCombine(m_file.filePath(), "mcmod.info")); if (mcmod_info.isFile()) { QFile mcmod(mcmod_info.filePath()); @@ -278,7 +278,7 @@ bool Mod::replace(Mod &with) } if (t == MOD_FOLDER) { - success = copyPath(with.m_file.filePath(), m_file.path()); + success = FS::copyPath(with.m_file.filePath(), m_file.path()); } if (success) { diff --git a/logic/minecraft/ModList.cpp b/logic/minecraft/ModList.cpp index 8f1bc041..60f8b012 100644 --- a/logic/minecraft/ModList.cpp +++ b/logic/minecraft/ModList.cpp @@ -14,7 +14,7 @@ */ #include "ModList.h" -#include <pathutils.h> +#include <FileSystem.h> #include <QMimeData> #include <QUrl> #include <QUuid> @@ -25,7 +25,7 @@ ModList::ModList(const QString &dir, const QString &list_file) : QAbstractListModel(), m_dir(dir), m_list_file(list_file) { - ensureFolderPathExists(m_dir.absolutePath()); + FS::ensureFolderPathExists(m_dir.absolutePath()); m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | QDir::NoSymLinks); m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); @@ -270,7 +270,7 @@ bool ModList::installMod(const QFileInfo &filename, int index) return false; if (type == Mod::MOD_SINGLEFILE || type == Mod::MOD_ZIPFILE || type == Mod::MOD_LITEMOD) { - QString newpath = PathCombine(m_dir.path(), filename.fileName()); + QString newpath = FS::PathCombine(m_dir.path(), filename.fileName()); if (!QFile::copy(filename.filePath(), newpath)) return false; m.repath(newpath); @@ -285,8 +285,8 @@ bool ModList::installMod(const QFileInfo &filename, int index) { QString from = filename.filePath(); - QString to = PathCombine(m_dir.path(), filename.fileName()); - if (!copyPath(from, to)) + QString to = FS::PathCombine(m_dir.path(), filename.fileName()); + if (!FS::copyPath(from, to)) return false; m.repath(to); beginInsertRows(QModelIndex(), index, index); diff --git a/logic/minecraft/OneSixInstance.cpp b/logic/minecraft/OneSixInstance.cpp index a5be8354..da1b21cb 100644 --- a/logic/minecraft/OneSixInstance.cpp +++ b/logic/minecraft/OneSixInstance.cpp @@ -14,7 +14,6 @@ */ #include <QIcon> -#include <pathutils.h> #include <QDebug> #include "minecraft/OneSixInstance.h" @@ -36,6 +35,7 @@ #include "minecraft/AssetsUtils.h" #include "icons/IconList.h" #include "minecraft/WorldList.h" +#include <FileSystem.h> OneSixInstance::OneSixInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) : MinecraftInstance(globalSettings, settings, rootDir) @@ -136,7 +136,7 @@ std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr sess QString launchScript; QIcon icon = ENV.icons()->getIcon(iconKey()); auto pixmap = icon.pixmap(128, 128); - pixmap.save(PathCombine(minecraftRoot(), "icon.png"), "PNG"); + pixmap.save(FS::PathCombine(minecraftRoot(), "icon.png"), "PNG"); if (!m_version) return nullptr; @@ -222,7 +222,7 @@ std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr sess // native libraries (mostly LWJGL) { - QDir natives_dir(PathCombine(instanceRoot(), "natives/")); + QDir natives_dir(FS::PathCombine(instanceRoot(), "natives/")); for (auto native : m_version->getActiveNativeLibs()) { QFileInfo finfo(native->storagePath()); @@ -348,7 +348,7 @@ std::shared_ptr<Task> OneSixInstance::createJarModdingTask() void OneSixInstance::cleanupAfterRun() { - QString target_dir = PathCombine(instanceRoot(), "natives/"); + QString target_dir = FS::PathCombine(instanceRoot(), "natives/"); QDir dir(target_dir); dir.removeRecursively(); } @@ -515,42 +515,42 @@ bool OneSixInstance::reload() QString OneSixInstance::loaderModsDir() const { - return PathCombine(minecraftRoot(), "mods"); + return FS::PathCombine(minecraftRoot(), "mods"); } QString OneSixInstance::coreModsDir() const { - return PathCombine(minecraftRoot(), "coremods"); + return FS::PathCombine(minecraftRoot(), "coremods"); } QString OneSixInstance::resourcePacksDir() const { - return PathCombine(minecraftRoot(), "resourcepacks"); + return FS::PathCombine(minecraftRoot(), "resourcepacks"); } QString OneSixInstance::texturePacksDir() const { - return PathCombine(minecraftRoot(), "texturepacks"); + return FS::PathCombine(minecraftRoot(), "texturepacks"); } QString OneSixInstance::instanceConfigFolder() const { - return PathCombine(minecraftRoot(), "config"); + return FS::PathCombine(minecraftRoot(), "config"); } QString OneSixInstance::jarModsDir() const { - return PathCombine(instanceRoot(), "jarmods"); + return FS::PathCombine(instanceRoot(), "jarmods"); } QString OneSixInstance::libDir() const { - return PathCombine(minecraftRoot(), "lib"); + return FS::PathCombine(minecraftRoot(), "lib"); } QString OneSixInstance::worldDir() const { - return PathCombine(minecraftRoot(), "saves"); + return FS::PathCombine(minecraftRoot(), "saves"); } QStringList OneSixInstance::extraArguments() const diff --git a/logic/minecraft/OneSixProfileStrategy.cpp b/logic/minecraft/OneSixProfileStrategy.cpp index f5de690b..85e9491c 100644 --- a/logic/minecraft/OneSixProfileStrategy.cpp +++ b/logic/minecraft/OneSixProfileStrategy.cpp @@ -3,8 +3,8 @@ #include "minecraft/OneSixInstance.h" #include "minecraft/MinecraftVersionList.h" #include "Env.h" +#include <FileSystem.h> -#include <pathutils.h> #include <QDir> #include <QUuid> #include <QJsonDocument> @@ -17,9 +17,9 @@ OneSixProfileStrategy::OneSixProfileStrategy(OneSixInstance* instance) void OneSixProfileStrategy::upgradeDeprecatedFiles() { - auto versionJsonPath = PathCombine(m_instance->instanceRoot(), "version.json"); - auto customJsonPath = PathCombine(m_instance->instanceRoot(), "custom.json"); - auto mcJson = PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json"); + auto versionJsonPath = FS::PathCombine(m_instance->instanceRoot(), "version.json"); + auto customJsonPath = FS::PathCombine(m_instance->instanceRoot(), "custom.json"); + auto mcJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json"); QString sourceFile; QString renameFile; @@ -36,7 +36,7 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles() } if(!sourceFile.isEmpty() && !QFile::exists(mcJson)) { - if(!ensureFilePathExists(mcJson)) + if(!FS::ensureFilePathExists(mcJson)) { qWarning() << "Couldn't create patches folder for" << m_instance->name(); return; @@ -79,7 +79,7 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles() void OneSixProfileStrategy::loadDefaultBuiltinPatches() { { - auto mcJson = PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json"); + auto mcJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json"); // load up the base minecraft patch ProfilePatchPtr minecraftPatch; if(QFile::exists(mcJson)) @@ -107,7 +107,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches() } { - auto lwjglJson = PathCombine(m_instance->instanceRoot(), "patches" , "org.lwjgl.json"); + auto lwjglJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "org.lwjgl.json"); ProfilePatchPtr lwjglPatch; if(QFile::exists(lwjglJson)) { @@ -138,8 +138,8 @@ void OneSixProfileStrategy::loadUserPatches() { // load all patches, put into map for ordering, apply in the right order ProfileUtils::PatchOrder userOrder; - ProfileUtils::readOverrideOrders(PathCombine(m_instance->instanceRoot(), "order.json"), userOrder); - QDir patches(PathCombine(m_instance->instanceRoot(),"patches")); + ProfileUtils::readOverrideOrders(FS::PathCombine(m_instance->instanceRoot(), "order.json"), userOrder); + QDir patches(FS::PathCombine(m_instance->instanceRoot(),"patches")); // first, load things by sort order. for (auto id : userOrder) @@ -215,7 +215,7 @@ void OneSixProfileStrategy::load() bool OneSixProfileStrategy::saveOrder(ProfileUtils::PatchOrder order) { - return ProfileUtils::writeOverrideOrders(PathCombine(m_instance->instanceRoot(), "order.json"), order); + return ProfileUtils::writeOverrideOrders(FS::PathCombine(m_instance->instanceRoot(), "order.json"), order); } bool OneSixProfileStrategy::resetOrder() @@ -241,7 +241,7 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch) auto preRemoveJarMod = [&](JarmodPtr jarMod) -> bool { - QString fullpath = PathCombine(m_instance->jarModsDir(), jarMod->name); + QString fullpath = FS::PathCombine(m_instance->jarModsDir(), jarMod->name); QFileInfo finfo (fullpath); if(finfo.exists()) { @@ -270,8 +270,8 @@ bool OneSixProfileStrategy::customizePatch(ProfilePatchPtr patch) return false; } - auto filename = PathCombine(m_instance->instanceRoot(), "patches" , patch->getPatchID() + ".json"); - if(!ensureFilePathExists(filename)) + auto filename = FS::PathCombine(m_instance->instanceRoot(), "patches" , patch->getPatchID() + ".json"); + if(!FS::ensureFilePathExists(filename)) { return false; } @@ -333,13 +333,13 @@ bool OneSixProfileStrategy::revertPatch(ProfilePatchPtr patch) bool OneSixProfileStrategy::installJarMods(QStringList filepaths) { - QString patchDir = PathCombine(m_instance->instanceRoot(), "patches"); - if(!ensureFolderPathExists(patchDir)) + QString patchDir = FS::PathCombine(m_instance->instanceRoot(), "patches"); + if(!FS::ensureFolderPathExists(patchDir)) { return false; } - if (!ensureFolderPathExists(m_instance->jarModsDir())) + if (!FS::ensureFolderPathExists(m_instance->jarModsDir())) { return false; } @@ -352,7 +352,7 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths) QString target_filename = id + ".jar"; QString target_id = "org.multimc.jarmod." + id; QString target_name = sourceInfo.completeBaseName() + " (jar mod)"; - QString finalPath = PathCombine(m_instance->jarModsDir(), target_filename); + QString finalPath = FS::PathCombine(m_instance->jarModsDir(), target_filename); QFileInfo targetInfo(finalPath); if(targetInfo.exists()) @@ -373,7 +373,7 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths) f->name = target_name; f->fileId = target_id; f->order = profile->getFreeOrderNumber(); - QString patchFileName = PathCombine(patchDir, target_id + ".json"); + QString patchFileName = FS::PathCombine(patchDir, target_id + ".json"); f->filename = patchFileName; f->setMovable(true); f->setRemovable(true); diff --git a/logic/minecraft/OneSixUpdate.cpp b/logic/minecraft/OneSixUpdate.cpp index 34bd7de9..73d48461 100644 --- a/logic/minecraft/OneSixUpdate.cpp +++ b/logic/minecraft/OneSixUpdate.cpp @@ -22,7 +22,6 @@ #include <QFileInfo> #include <QTextStream> #include <QDataStream> -#include <pathutils.h> #include <JlCompress.h> #include "BaseInstance.h" @@ -35,6 +34,7 @@ #include "minecraft/AssetsUtils.h" #include "Exception.h" #include "MMCZip.h" +#include <FileSystem.h> OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent), m_inst(inst) { @@ -344,7 +344,7 @@ void OneSixUpdate::fmllibsStart() // now check the lib folder inside the instance for files. for (auto &lib : libList) { - QFileInfo libInfo(PathCombine(inst->libDir(), lib.filename)); + QFileInfo libInfo(FS::PathCombine(inst->libDir(), lib.filename)); if (libInfo.exists()) continue; fmlLibsToProcess.append(lib); @@ -389,13 +389,13 @@ void OneSixUpdate::fmllibsFinished() { progress(index, fmlLibsToProcess.size()); auto entry = metacache->resolveEntry("fmllibs", lib.filename); - auto path = PathCombine(inst->libDir(), lib.filename); - if (!ensureFilePathExists(path)) + auto path = FS::PathCombine(inst->libDir(), lib.filename); + if (!FS::ensureFilePathExists(path)) { emitFailed(tr("Failed creating FML library folder inside the instance.")); return; } - if (!QFile::copy(entry->getFullPath(), PathCombine(inst->libDir(), lib.filename))) + if (!QFile::copy(entry->getFullPath(), FS::PathCombine(inst->libDir(), lib.filename))) { emitFailed(tr("Failed copying Forge/FML library: %1.").arg(lib.filename)); return; diff --git a/logic/minecraft/RawLibrary.cpp b/logic/minecraft/RawLibrary.cpp index ceaa9dd0..7da743e4 100644 --- a/logic/minecraft/RawLibrary.cpp +++ b/logic/minecraft/RawLibrary.cpp @@ -2,7 +2,7 @@ using namespace Json; #include "RawLibrary.h" -#include <pathutils.h> +#include <FileSystem.h> RawLibraryPtr RawLibrary::fromJson(const QJsonObject &libObj, const QString &filename) { @@ -314,7 +314,7 @@ QString RawLibrary::storageSuffix() const QString RawLibrary::storagePath() const { - return PathCombine(storagePrefix(), storageSuffix()); + return FS::PathCombine(storagePrefix(), storageSuffix()); } bool RawLibrary::storagePathIsDefault() const diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp index 24f2eb9c..922ba470 100644 --- a/logic/minecraft/VersionFile.cpp +++ b/logic/minecraft/VersionFile.cpp @@ -1,6 +1,5 @@ #include <QJsonArray> #include <QJsonDocument> -#include <modutils.h> #include <QDebug> @@ -14,6 +13,7 @@ using namespace Json; #include "VersionBuildError.h" +#include <Version.h> #define CURRENT_MINIMUM_LAUNCHER_VERSION 14 @@ -427,8 +427,8 @@ void VersionFile::applyTo(MinecraftProfile *version) // otherwise apply differences, if allowed auto existingLibrary = version->libraries.at(index); - const Util::Version addedVersion = addedLibrary->version(); - const Util::Version existingVersion = existingLibrary->version(); + const Version addedVersion(addedLibrary->version()); + const Version existingVersion(existingLibrary->version()); // if the existing version is a hard dependency we can either use it or // fail, but we can't change it if (existingLibrary->dependType == OneSixLibrary::Hard) diff --git a/logic/minecraft/World.cpp b/logic/minecraft/World.cpp index 41d62b1b..e4734556 100644 --- a/logic/minecraft/World.cpp +++ b/logic/minecraft/World.cpp @@ -18,10 +18,10 @@ #include <QDebug> #include <QSaveFile> #include "World.h" -#include <pathutils.h> #include "GZip.h" #include <MMCZip.h> +#include <FileSystem.h> #include <sstream> #include <io/stream_reader.h> #include <tag_string.h> @@ -179,8 +179,8 @@ void World::readFromZip(const QFileInfo &file) bool World::install(const QString &to, const QString &name) { - auto finalPath = PathCombine(to, DirNameFromString(m_actualName, to)); - if(!ensureFolderPathExists(finalPath)) + auto finalPath = FS::PathCombine(to, FS::DirNameFromString(m_actualName, to)); + if(!FS::ensureFolderPathExists(finalPath)) { return false; } @@ -197,7 +197,7 @@ bool World::install(const QString &to, const QString &name) else if(m_containerFile.isDir()) { QString from = m_containerFile.filePath(); - ok = copyPath(from, finalPath); + ok = FS::copyPath(from, finalPath); } if(ok && !name.isEmpty() && m_actualName != name) @@ -245,7 +245,7 @@ bool World::rename(const QString &newName) QDir parentDir(m_containerFile.absoluteFilePath()); parentDir.cdUp(); QFile container(m_containerFile.absoluteFilePath()); - auto dirName = DirNameFromString(m_actualName, parentDir.absolutePath()); + auto dirName = FS::DirNameFromString(m_actualName, parentDir.absolutePath()); container.rename(parentDir.absoluteFilePath(dirName)); return true; @@ -350,7 +350,7 @@ bool World::replace(World &with) { if (!destroy()) return false; - bool success = copyPath(with.m_containerFile.filePath(), m_containerFile.path()); + bool success = FS::copyPath(with.m_containerFile.filePath(), m_containerFile.path()); if (success) { m_folderName = with.m_folderName; diff --git a/logic/minecraft/WorldList.cpp b/logic/minecraft/WorldList.cpp index fff4f74a..42c8a3e6 100644 --- a/logic/minecraft/WorldList.cpp +++ b/logic/minecraft/WorldList.cpp @@ -14,7 +14,7 @@ */ #include "WorldList.h" -#include <pathutils.h> +#include <FileSystem.h> #include <QMimeData> #include <QUrl> #include <QUuid> @@ -25,7 +25,7 @@ WorldList::WorldList(const QString &dir) : QAbstractListModel(), m_dir(dir) { - ensureFolderPathExists(m_dir.absolutePath()); + FS::ensureFolderPathExists(m_dir.absolutePath()); m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | QDir::NoSymLinks); m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); |