diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-01-20 01:32:38 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-01-20 01:32:38 +0100 |
commit | 222d3c0dc5a8b8a9e93b9368e964cda7becc7f02 (patch) | |
tree | 9ab4538f2e80847874a7c9a5c7c2dbc099cb8cae /logic/OneSixLibrary.cpp | |
parent | 48b587e7b6b96b5c3ac17dc8b67a7b0ab9c2c4f0 (diff) | |
parent | 3a3c9ac9515447941d383f2c4fe4b0225fdd8252 (diff) | |
download | PrismLauncher-222d3c0dc5a8b8a9e93b9368e964cda7becc7f02.tar.gz PrismLauncher-222d3c0dc5a8b8a9e93b9368e964cda7becc7f02.tar.bz2 PrismLauncher-222d3c0dc5a8b8a9e93b9368e964cda7becc7f02.zip |
Merge branch 'release-0.2'
Diffstat (limited to 'logic/OneSixLibrary.cpp')
-rw-r--r-- | logic/OneSixLibrary.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/logic/OneSixLibrary.cpp b/logic/OneSixLibrary.cpp index 4b6ed9dc..d1eceb0e 100644 --- a/logic/OneSixLibrary.cpp +++ b/logic/OneSixLibrary.cpp @@ -19,6 +19,9 @@ #include "OneSixRule.h" #include "OpSys.h" #include "logic/net/URLConstants.h" +#include <pathutils.h> +#include <JlCompress.h> +#include "logger/QsLog.h" void OneSixLibrary::finalize() { @@ -133,6 +136,90 @@ QString OneSixLibrary::hint() return m_hint; } +bool OneSixLibrary::filesExist() +{ + QString storage = storagePath(); + if (storage.contains("${arch}")) + { + QString cooked_storage = storage; + cooked_storage.replace("${arch}", "32"); + QFileInfo info32(PathCombine("libraries", cooked_storage)); + if (!info32.exists()) + { + return false; + } + cooked_storage = storage; + cooked_storage.replace("${arch}", "64"); + QFileInfo info64(PathCombine("libraries", cooked_storage)); + if (!info64.exists()) + { + return false; + } + } + else + { + QFileInfo info(PathCombine("libraries", storage)); + if (!info.exists()) + { + return false; + } + } + return true; +} + +bool OneSixLibrary::extractTo(QString target_dir) +{ + QString storage = storagePath(); + if (storage.contains("${arch}")) + { + QString cooked_storage = storage; + cooked_storage.replace("${arch}", "32"); + QString origin = PathCombine("libraries", cooked_storage); + QString target_dir_cooked = PathCombine(target_dir, "32"); + if(!ensureFolderPathExists(target_dir_cooked)) + { + QLOG_ERROR() << "Couldn't create folder " + target_dir_cooked; + return false; + } + if (JlCompress::extractWithExceptions(origin, target_dir_cooked, extract_excludes) + .isEmpty()) + { + QLOG_ERROR() << "Couldn't extract " + origin; + return false; + } + cooked_storage = storage; + cooked_storage.replace("${arch}", "64"); + origin = PathCombine("libraries", cooked_storage); + target_dir_cooked = PathCombine(target_dir, "32"); + if(!ensureFolderPathExists(target_dir_cooked)) + { + QLOG_ERROR() << "Couldn't create folder " + target_dir_cooked; + return false; + } + if (JlCompress::extractWithExceptions(origin, target_dir_cooked, extract_excludes) + .isEmpty()) + { + QLOG_ERROR() << "Couldn't extract " + origin; + return false; + } + } + else + { + if(!ensureFolderPathExists(target_dir)) + { + QLOG_ERROR() << "Couldn't create folder " + target_dir; + return false; + } + QString path = PathCombine("libraries", storage); + if (JlCompress::extractWithExceptions(path, target_dir, extract_excludes).isEmpty()) + { + QLOG_ERROR() << "Couldn't extract " + path; + return false; + } + } + return true; +} + QJsonObject OneSixLibrary::toJson() { QJsonObject libRoot; |