mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-11-08 11:31:43 +00:00
Don't try to overwrite aio when it's running https://github.com/HamletDuFromage/aio-switch-updater/issues/123#issuecomment-1208878115
This commit is contained in:
parent
66a24674b2
commit
1e9f453998
5 changed files with 28 additions and 19 deletions
|
@ -6,6 +6,7 @@
|
|||
#include <set>
|
||||
|
||||
namespace fs {
|
||||
std::vector<std::string> splitString(const std::string& s, char delimiter);
|
||||
bool removeDir(const std::string& path);
|
||||
nlohmann::ordered_json parseJsonFile(const std::string& path);
|
||||
void writeJsonToFile(nlohmann::json& data, const std::string& path);
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace util {
|
|||
std::string getCheatsVersion();
|
||||
void saveToFile(const std::string& text, const std::string& path);
|
||||
std::string readFile(const std::string& path);
|
||||
std::string getAppPath();
|
||||
bool isErista();
|
||||
void removeSysmodulesFlags(const std::string& directory);
|
||||
std::string lowerCase(const std::string& str);
|
||||
|
|
|
@ -101,36 +101,37 @@ namespace extract {
|
|||
ProgressEvent::instance().setStep(0);
|
||||
|
||||
std::set<std::string> ignoreList = fs::readLineByLine(FILES_IGNORE);
|
||||
std::string appPath = util::getAppPath();
|
||||
|
||||
for (uLong i = 0; i < gi.number_entry; ++i) {
|
||||
char szFilename[0x301] = "";
|
||||
unzOpenCurrentFile(zfile);
|
||||
unzGetCurrentFileInfo(zfile, NULL, szFilename, sizeof(szFilename), NULL, 0, NULL, 0);
|
||||
std::string filename = szFilename;
|
||||
// brls::Logger::debug("Going over {} in {}", filename, archivePath);
|
||||
|
||||
if (ProgressEvent::instance().getInterupt()) {
|
||||
unzCloseCurrentFile(zfile);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((overwriteInis == 0 && filename.substr(filename.length() - 4) == ".ini") || std::find_if(ignoreList.begin(), ignoreList.end(), [&filename](std::string ignored) {
|
||||
if (appPath != workingPath + filename) {
|
||||
if ((overwriteInis == 0 && filename.substr(filename.length() - 4) == ".ini") || std::find_if(ignoreList.begin(), ignoreList.end(), [&filename](std::string ignored) {
|
||||
u8 res = ("/" + filename).find(ignored);
|
||||
return (res == 0 || res == 1); }) != ignoreList.end()) {
|
||||
if (!std::filesystem::exists("/" + filename)) {
|
||||
extractEntry(filename, zfile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((filename == "atmosphere/package3") || (filename == "atmosphere/stratosphere.romfs")) {
|
||||
extractEntry(filename += ".aio", zfile);
|
||||
if (!std::filesystem::exists("/" + filename)) {
|
||||
extractEntry(filename, zfile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
extractEntry(filename, zfile);
|
||||
if (filename.substr(0, 13) == "hekate_ctcaer") {
|
||||
fs::copyFile("/" + filename, UPDATE_BIN_PATH);
|
||||
if (CurrentCfw::running_cfw == CFW::ams && util::showDialogBoxBlocking(fmt::format("menus/utils/set_hekate_reboot_payload"_i18n, UPDATE_BIN_PATH, REBOOT_PAYLOAD_PATH), "menus/common/yes"_i18n, "menus/common/no"_i18n) == 0) {
|
||||
fs::copyFile(UPDATE_BIN_PATH, REBOOT_PAYLOAD_PATH);
|
||||
if ((filename == "atmosphere/package3") || (filename == "atmosphere/stratosphere.romfs")) {
|
||||
extractEntry(filename += ".aio", zfile);
|
||||
}
|
||||
else {
|
||||
extractEntry(filename, zfile);
|
||||
if (filename.substr(0, 13) == "hekate_ctcaer") {
|
||||
fs::copyFile("/" + filename, UPDATE_BIN_PATH);
|
||||
if (CurrentCfw::running_cfw == CFW::ams && util::showDialogBoxBlocking(fmt::format("menus/utils/set_hekate_reboot_payload"_i18n, UPDATE_BIN_PATH, REBOOT_PAYLOAD_PATH), "menus/common/yes"_i18n, "menus/common/no"_i18n) == 0) {
|
||||
fs::copyFile(UPDATE_BIN_PATH, REBOOT_PAYLOAD_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
namespace i18n = brls::i18n;
|
||||
using namespace i18n::literals;
|
||||
|
||||
namespace {
|
||||
namespace fs {
|
||||
std::vector<std::string> splitString(const std::string& s, char delimiter)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
|
@ -20,9 +20,6 @@ namespace {
|
|||
}
|
||||
return tokens;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace fs {
|
||||
|
||||
bool removeDir(const std::string& path)
|
||||
{
|
||||
|
|
|
@ -292,6 +292,15 @@ namespace util {
|
|||
return text;
|
||||
}
|
||||
|
||||
std::string getAppPath()
|
||||
{
|
||||
if (envHasArgv()) {
|
||||
std::string argv = (char*)envGetArgv();
|
||||
return fs::splitString(argv, '\"')[1].substr(5);
|
||||
}
|
||||
return NRO_PATH;
|
||||
}
|
||||
|
||||
bool isErista()
|
||||
{
|
||||
SetSysProductModel model;
|
||||
|
|
Loading…
Reference in a new issue