diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-01-18 03:32:31 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-01-18 03:33:04 +0100 |
commit | ecc80bd763111b0e368aa80366bd8382cd814ee6 (patch) | |
tree | 5f910b6b571653c79193e2a7a46236111d13fec5 /logic/OneSixLibrary.cpp | |
parent | 188d0d58865f5e134b5803bda2cd631a61cf2915 (diff) | |
download | PrismLauncher-ecc80bd763111b0e368aa80366bd8382cd814ee6.tar.gz PrismLauncher-ecc80bd763111b0e368aa80366bd8382cd814ee6.tar.bz2 PrismLauncher-ecc80bd763111b0e368aa80366bd8382cd814ee6.zip |
Change the native extraction/loading logic.
Diffstat (limited to 'logic/OneSixLibrary.cpp')
-rw-r--r-- | logic/OneSixLibrary.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/logic/OneSixLibrary.cpp b/logic/OneSixLibrary.cpp index 4b6ed9dc..1d69b660 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,59 @@ QString OneSixLibrary::hint() return m_hint; } +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; |