diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-10-02 00:26:10 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-10-02 00:26:10 +0200 |
commit | 6e80f03409054293bdbbcd0ce87b607a811016d5 (patch) | |
tree | d64d9034d797a9c619cca4bad5ff0ef1dfb73165 /api/logic/minecraft/Library.cpp | |
parent | 69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91 (diff) | |
download | MultiMC-6e80f03409054293bdbbcd0ce87b607a811016d5.tar MultiMC-6e80f03409054293bdbbcd0ce87b607a811016d5.tar.gz MultiMC-6e80f03409054293bdbbcd0ce87b607a811016d5.tar.lz MultiMC-6e80f03409054293bdbbcd0ce87b607a811016d5.tar.xz MultiMC-6e80f03409054293bdbbcd0ce87b607a811016d5.zip |
NOISSUE add instance-local library storage
Any libraries stored in $instanceroot/libraries/ will override
the libraries from MultiMC's global folders, as long as they are marked 'local'
in the json patch.
Diffstat (limited to 'api/logic/minecraft/Library.cpp')
-rw-r--r-- | api/logic/minecraft/Library.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index c516edb7..8bbd5503 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -1,15 +1,31 @@ #include "Library.h" +#include "MinecraftInstance.h" + #include <net/Download.h> #include <net/ChecksumValidator.h> #include <minecraft/forge/ForgeXzDownload.h> #include <Env.h> #include <FileSystem.h> -void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32, QStringList& native64) const + +void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32, + QStringList& native64, const QString &overridePath) const { + bool isLocal = (hint() == "local"); auto actualPath = [&](QString relPath) { QFileInfo out(FS::PathCombine(storagePrefix(), relPath)); + if(isLocal && !overridePath.isEmpty()) + { + QString fileName = out.fileName(); + auto fullPath = FS::PathCombine(overridePath, fileName); + qDebug() << fullPath; + QFileInfo fileinfo(fullPath); + if(fileinfo.exists()) + { + return fileinfo.absoluteFilePath(); + } + } return out.absoluteFilePath(); }; if(m_mojangDownloads) @@ -69,7 +85,8 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na } } -QList<NetActionPtr> Library::getDownloads(OpSys system, HttpMetaCache * cache, QStringList &failedFiles) const +QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class HttpMetaCache* cache, + QStringList& failedFiles, const QString & overridePath) const { QList<NetActionPtr> out; bool isAlwaysStale = (hint() == "always-stale"); @@ -87,6 +104,25 @@ QList<NetActionPtr> Library::getDownloads(OpSys system, HttpMetaCache * cache, Q return true; if(isLocal) { + if(!overridePath.isEmpty()) + { + QString fileName; + int position = storage.lastIndexOf('/'); + if(position == -1) + { + fileName = storage; + } + else + { + fileName = storage.mid(position); + } + auto fullPath = FS::PathCombine(overridePath, fileName); + QFileInfo fileinfo(fullPath); + if(fileinfo.exists()) + { + return true; + } + } QFileInfo fileinfo(entry->getFullPath()); if(!fileinfo.exists()) { |