diff --git a/include/utils/cia.hpp b/include/utils/cia.hpp index 8235fb3..f1da4be 100644 --- a/include/utils/cia.hpp +++ b/include/utils/cia.hpp @@ -7,6 +7,6 @@ Result CIA_LaunchTitle(u64 titleId, FS_MediaType mediaType); Result deletePrevious(u64 titleid, FS_MediaType media); -Result installCia(const char * ciaPath); +Result installCia(const char * ciaPath, bool updateSelf); #endif \ No newline at end of file diff --git a/include/utils/scriptHelper.hpp b/include/utils/scriptHelper.hpp index 44e6de7..04639d8 100644 --- a/include/utils/scriptHelper.hpp +++ b/include/utils/scriptHelper.hpp @@ -67,7 +67,7 @@ namespace ScriptHelper { Result downloadFile(std::string file, std::string output, std::string message); Result removeFile(std::string file, std::string message); - void installFile(std::string file, std::string message); + void installFile(std::string file, bool updateSelf, std::string message); void extractFile(std::string file, std::string input, std::string output, std::string message); Result createFile(const char * path); void displayTimeMsg(std::string message, int seconds); diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index 8cc307f..6434d7d 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -935,12 +935,15 @@ Result ScriptList::runFunctions(nlohmann::json &json) { else ret = SYNTAX_ERROR; } else if(type == "installCia") { - bool missing = false; + bool missing = false, updateSelf = false; std::string file, message; if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file"); else missing = true; + if(json.at(choice).at(i).contains("updateSelf") && json.at(choice).at(i).at("updateSelf").is_boolean()) { + updateSelf = json.at(choice).at(i).at("updateSelf"); + } if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message"); - if(!missing) ScriptHelper::installFile(file, message); + if(!missing) ScriptHelper::installFile(file, updateSelf, message); else ret = SYNTAX_ERROR; } else if (type == "mkdir") { diff --git a/source/screens/unistore.cpp b/source/screens/unistore.cpp index 502446f..9245a5c 100644 --- a/source/screens/unistore.cpp +++ b/source/screens/unistore.cpp @@ -1264,12 +1264,15 @@ Result UniStore::execute() { else ret = SYNTAX_ERROR; } else if(type == "installCia") { - bool missing = false; + bool missing = false, updateSelf = false; std::string file, message; if(appStoreJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = appStoreJson.at("storeContent").at(Selection).at("script").at(i).at("file"); else missing = true; + if(appStoreJson.at("storeContent").at(Selection).at("script").at(i).contains("updateSelf") && appStoreJson.at("storeContent").at(Selection).at("script").at(i).at("updateSelf").is_boolean()) { + updateSelf = appStoreJson.at("storeContent").at(Selection).at("script").at(i).at("updateSelf"); + } if(appStoreJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = appStoreJson.at("storeContent").at(Selection).at("script").at(i).at("message"); - if(!missing) ScriptHelper::installFile(file, message); + if(!missing) ScriptHelper::installFile(file, updateSelf, message); else ret = SYNTAX_ERROR; } else if (type == "mkdir") { diff --git a/source/utils/cia.cpp b/source/utils/cia.cpp index 3be6499..27deec3 100644 --- a/source/utils/cia.cpp +++ b/source/utils/cia.cpp @@ -1,7 +1,5 @@ #include "cia.hpp" -bool updatingSelf = false; - Result CIA_LaunchTitle(u64 titleId, FS_MediaType mediaType) { Result ret = 0; u8 param[0x300]; @@ -67,7 +65,7 @@ FS_MediaType getTitleDestination(u64 titleId) { // Variables. u64 installSize = 0, installOffset = 0; -Result installCia(const char * ciaPath) +Result installCia(const char * ciaPath, bool updatingSelf) { u32 bytes_read = 0, bytes_written; installSize = 0, installOffset = 0; u64 size = 0; @@ -89,9 +87,6 @@ Result installCia(const char * ciaPath) } media = getTitleDestination(info.titleID); - if (info.titleID == 0x0004000004391700) { - updatingSelf = true; - } if (!updatingSelf) { ret = deletePrevious(info.titleID, media); diff --git a/source/utils/scriptHelper.cpp b/source/utils/scriptHelper.cpp index ac27758..b78f265 100644 --- a/source/utils/scriptHelper.cpp +++ b/source/utils/scriptHelper.cpp @@ -106,12 +106,12 @@ Result ScriptHelper::removeFile(std::string file, std::string message) { } // Install a file. -void ScriptHelper::installFile(std::string file, std::string message) { +void ScriptHelper::installFile(std::string file, bool updatingSelf, std::string message) { snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str()); showProgressBar = true; progressBarType = 2; Threads::create((ThreadFunc)displayProgressBar); - installCia(file.c_str()); + installCia(file.c_str(), updatingSelf); showProgressBar = false; }