diff --git a/copy_files.txt b/copy_files.txt new file mode 100644 index 0000000..e16e279 --- /dev/null +++ b/copy_files.txt @@ -0,0 +1,3 @@ +/hekate_ctcaer_5.5.6.bin|/lol.bin +/hekate_ctcaer_5.5.6.bin|/xd.bin +/bootloader/update.bin|/config/aio-switch-updater/looool \ No newline at end of file diff --git a/include/color_swapper.hpp b/include/color_swapper.hpp index c76cba6..7485151 100644 --- a/include/color_swapper.hpp +++ b/include/color_swapper.hpp @@ -5,22 +5,22 @@ namespace JC { int setColor(std::vector colors); - int backupToJSON(nlohmann::json &profiles, const char* path); - std::vector>> getProfiles(const char* path); + int backupToJSON(nlohmann::json &profiles, const std::string& path); + std::vector>> getProfiles(const std::string& path); void changeJCColor(std::vector values); nlohmann::json backupProfile(); - void backupJCColor(const char* path); + void backupJCColor(const std::string& path); } namespace PC { int setColor(std::vector colors); - int backupToJSON(nlohmann::json &profiles, const char* path); - std::vector>> getProfiles(const char* path); + int backupToJSON(nlohmann::json &profiles,const std::string& path); + std::vector>> getProfiles(const std::string& path); void changePCColor(std::vector values); nlohmann::json backupProfile(); - void backupPCColor(const char* path); + void backupPCColor(const std::string& path); } diff --git a/include/constants.hpp b/include/constants.hpp index 42c116e..ada1fcc 100644 --- a/include/constants.hpp +++ b/include/constants.hpp @@ -81,9 +81,9 @@ constexpr const char SEPT_DIRECTORY_PATH[] ="/config/aio-switch-updater/sept/"; constexpr const char FW_DIRECTORY_PATH[] = "/firmware/"; constexpr const char HIDE_TABS_JSON[] = "/config/aio-switch-updater/hide_tabs.json"; -constexpr const char COPY_FILES_JSON[] = "/config/aio-switch-updater/copy_files.json"; +constexpr const char COPY_FILES_TXT[] = "/config/aio-switch-updater/copy_files.txt"; constexpr const char LANGUAGE_JSON[] = "/config/aio-switch-updater/language.json"; -constexpr const char HOMEBREW[] = "/config/aio-switch-updater/language.json"; +constexpr const char HOMEBREW[] = "/config/aio-switch-updater/language.json"; constexpr const char ROMFS_FORWARDER[] = "romfs:/aiosu-forwarder.nro"; constexpr const char FORWARDER_PATH[] = "/config/aio-switch-updater/aiosu-forwarder.nro"; diff --git a/include/download.hpp b/include/download.hpp index fd60654..510d5ac 100644 --- a/include/download.hpp +++ b/include/download.hpp @@ -7,11 +7,11 @@ constexpr int OFF = 0; namespace download { - std::vector downloadFile(const char *url, const char *output = "", int api = OFF); - std::vector> getLinks(const char *url); - std::string fetchTitle(const char *url); - std::string downloadPage(const char* url, std::vector headers = {}, std::string body = ""); - std::vector downloadPageBinary(const char* url, std::vector headers = {}, std::string body = ""); - nlohmann::ordered_json getRequest(std::string url, std::vector headers = {}, std::string body = ""); + std::vector downloadFile(const std::string& url, const char* output = "", int api = OFF); + std::vector> getLinks(const std::string& url); + std::string fetchTitle(const std::string& url); + std::string downloadPage(const std::string& url, std::vector headers = {}, std::string body = ""); + std::vector downloadPageBinary(const std::string& url, std::vector headers = {}, std::string body = ""); + nlohmann::ordered_json getRequest(const std::string& url, std::vector headers = {}, std::string body = ""); } \ No newline at end of file diff --git a/include/extract.hpp b/include/extract.hpp index 6f0f26f..8136f5c 100644 --- a/include/extract.hpp +++ b/include/extract.hpp @@ -22,13 +22,13 @@ namespace extract { } } Title; - void extract(const char* filename, const char* workingPath = ROOT_PATH, int overwriteInis = 1); - void extract(const char * filename, const char* workingPath, const char* toExclude); + void extract(const std::string& filename, const std::string& workingPath = ROOT_PATH, int overwriteInis = 1); + void extract(const std::string& filename, const std::string& workingPath, const std::string& toExclude); std::vector getInstalledTitlesNs(); - std::vector excludeTitles(const char* path, std::vector listedTitles); - void writeTitlesToFile(std::set titles, const char* path); - void extractCheats(const char * zipPath, std::vector titles, CFW cfw, bool credits = false); - void extractAllCheats(const char * zipPath, CFW cfw); + std::vector excludeTitles(const std::string& path, std::vector listedTitles); + void writeTitlesToFile(std::set titles, const std::string& path); + void extractCheats(const std::string& zipPath, std::vector titles, CFW cfw, bool credits = false); + void extractAllCheats(const std::string& zipPath, CFW cfw); void removeCheats(CFW cfw); bool isBID(std::string bid); diff --git a/include/fs.hpp b/include/fs.hpp index b62a3e2..411cbdc 100644 --- a/include/fs.hpp +++ b/include/fs.hpp @@ -6,13 +6,11 @@ namespace fs { - int removeDir(const char* path); - nlohmann::json parseJsonFile(const char* path); - void writeJsonToFile(nlohmann::json &data, const char* path); - bool copyFile(const char *to, const char *from); - std::string copyFiles(const char* path); + nlohmann::ordered_json parseJsonFile(const std::string& path); + void writeJsonToFile(nlohmann::json &data, const std::string& path); + bool copyFile(const std::string& from, const std::string& to); + std::string copyFiles(const std::string& path); void createTree(std::string path); - std::set readLineByLine(const char * path); - + std::set readLineByLine(const std::string& path); } diff --git a/include/utils.hpp b/include/utils.hpp index f27d478..6f6ff53 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -20,7 +20,7 @@ namespace util { }; void clearConsole(); - bool isArchive(const char * path); + bool isArchive(const std::string& path); void downloadArchive(std::string url, archiveType type); void extractArchive(archiveType type, std::string tag = "0"); std::string formatListItemTitle(const std::string &str, size_t maxScore = 140); @@ -29,10 +29,10 @@ namespace util { void shutDown(bool reboot = false); int showDialogBox(std::string text, std::string opt); int showDialogBox(std::string text, std::string opt1, std::string opt2); - std::string getLatestTag(const char *url); - void saveVersion(std::string version, const char* path); - std::string readVersion(const char* path); + std::string getLatestTag(const std::string& url); + void saveVersion(std::string version, const std::string& path); + std::string readVersion(const std::string& path); bool isErista(); - void removeSysmodulesFlags(const char * directory); + void removeSysmodulesFlags(const std::string& directory); } \ No newline at end of file diff --git a/source/ams_tab.cpp b/source/ams_tab.cpp index bc5102d..f6cccb2 100644 --- a/source/ams_tab.cpp +++ b/source/ams_tab.cpp @@ -16,7 +16,7 @@ AmsTab::AmsTab(const bool erista) : { std::vector> links; std::string operation("menus/main/getting"_i18n); - this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "menus/main/ams_text"_i18n + (CurrentCfw::running_cfw == CFW::ams ? "\n" + "menus/ams_update/current_ams"_i18n + CurrentCfw::getAmsInfo() : "") + (erista ? "\n" + "menus/ams_update/ersita_rev"_i18n : "\n" + "menus/ams_update/mariko_rev"_i18n), true); + this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "menus/main/ams_text"_i18n + (CurrentCfw::running_cfw == CFW::ams ? "\n" + "menus/ams_update/current_ams"_i18n + CurrentCfw::getAmsInfo() : "") + (erista ? "\n" + "menus/ams_update/erista_rev"_i18n : "\n" + "menus/ams_update/mariko_rev"_i18n), true); this->addView(description); operation += "menus/main/ams"_i18n; links = download::getLinks(AMS_URL); diff --git a/source/color_swapper.cpp b/source/color_swapper.cpp index 71d80de..0791086 100644 --- a/source/color_swapper.cpp +++ b/source/color_swapper.cpp @@ -58,7 +58,7 @@ namespace JC { return res; } - int backupToJSON(json &profiles, const char* path){ + int backupToJSON(json &profiles, const std::string& path){ HidNpadControllerColor color_left; HidNpadControllerColor color_right; Result res = hidGetNpadControllerColorSplit(HidNpadIdType_Handheld, &color_left, &color_right); @@ -108,7 +108,7 @@ namespace JC { } - std::vector>> getProfiles(const char* path){ + std::vector>> getProfiles(const std::string& path){ std::vector>> res; bool properData; std::fstream profilesFile; @@ -163,7 +163,7 @@ namespace JC { ProgressEvent::instance().setStep(ProgressEvent::instance().getMax()); } - void backupJCColor(const char* path){ + void backupJCColor(const std::string& path){ hiddbgInitialize(); hidsysInitialize(); ProgressEvent::instance().reset(); @@ -222,7 +222,7 @@ namespace PC { return res; } - int backupToJSON(json &profiles, const char* path){ + int backupToJSON(json &profiles, const std::string& path){ HidNpadControllerColor color; Result res = hidGetNpadControllerColorSingle(HidNpadIdType_No1, &color); std::vector oldBackups; @@ -266,7 +266,7 @@ namespace PC { } - std::vector>> getProfiles(const char* path){ + std::vector>> getProfiles(const std::string& path){ std::vector>> res; bool properData; std::fstream profilesFile; @@ -315,7 +315,7 @@ namespace PC { ProgressEvent::instance().setStep(ProgressEvent::instance().getMax()); } - void backupPCColor(const char* path){ + void backupPCColor(const std::string& path){ hiddbgInitialize(); hidsysInitialize(); ProgressEvent::instance().reset(); diff --git a/source/dialogue_page.cpp b/source/dialogue_page.cpp index 70ddf51..7621ffc 100644 --- a/source/dialogue_page.cpp +++ b/source/dialogue_page.cpp @@ -9,7 +9,7 @@ namespace i18n = brls::i18n; using namespace i18n::literals; -DialoguePage::DialoguePage(brls::StagedAppletFrame* frame, std::string text, bool ersita) : erista(erista) +DialoguePage::DialoguePage(brls::StagedAppletFrame* frame, std::string text, bool erista) : erista(erista) { this->button1 = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/common/yes"_i18n); this->button1->setParent(this); diff --git a/source/download.cpp b/source/download.cpp index 1a6dbf4..ff66d75 100644 --- a/source/download.cpp +++ b/source/download.cpp @@ -100,7 +100,7 @@ namespace download { } -std::vector downloadFile(const char *url, const char *output, int api) +std::vector downloadFile(const std::string& url, const char* output, int api) { ProgressEvent::instance().reset(); CURL *curl = curl_easy_init(); @@ -116,7 +116,7 @@ std::vector downloadFile(const char *url, const char *output, int chunk.data_size = _1MiB; chunk.out = fp; - curl_easy_setopt(curl, CURLOPT_URL, url); + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, API_AGENT); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); @@ -154,7 +154,7 @@ std::vector downloadFile(const char *url, const char *output, int } -std::string fetchTitle(const char *url){ +std::string fetchTitle(const std::string& url){ CURL *curl_handle; struct MemoryStruct chunk; @@ -189,7 +189,7 @@ std::string fetchTitle(const char *url){ return ver; } -std::string downloadPage(const char* url, std::vector headers, std::string body){ +std::string downloadPage(const std::string& url, std::vector headers, std::string body){ std::string res; CURL *curl_handle; struct MemoryStruct chunk; @@ -200,7 +200,7 @@ std::string downloadPage(const char* url, std::vector headers, std: curl_global_init(CURL_GLOBAL_ALL); curl_handle = curl_easy_init(); - curl_easy_setopt(curl_handle, CURLOPT_URL, url); + curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str()); if(!headers.empty()){ for (auto& h : headers){ list = curl_slist_append(list, h.c_str()); @@ -225,7 +225,7 @@ std::string downloadPage(const char* url, std::vector headers, std: return res; } -std::vector downloadPageBinary(const char* url, std::vector headers, std::string body){ +std::vector downloadPageBinary(const std::string& url, std::vector headers, std::string body){ CURL *curl_handle; struct MemoryStruct chunk; struct curl_slist *list = NULL; @@ -260,15 +260,15 @@ std::vector downloadPageBinary(const char* url, std::vector headers, std::string body) { +nlohmann::ordered_json getRequest(const std::string& url, std::vector headers, std::string body) { std::string request; - request = downloadPage(url.c_str(), headers, body); + request = downloadPage(url, headers, body); if(json::accept(request)) return nlohmann::ordered_json::parse(request); else return nlohmann::ordered_json::object(); } -std::vector> getLinks(const char *url) { +std::vector> getLinks(const std::string& url) { std::string request; request = downloadPage(url); diff --git a/source/download_cheats_page.cpp b/source/download_cheats_page.cpp index 1565b0b..2314142 100644 --- a/source/download_cheats_page.cpp +++ b/source/download_cheats_page.cpp @@ -31,7 +31,7 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true) if(bid != "") { std::vector headers = {"accept: application/json"}; - json cheatsInfo = download::getRequest((CHEATSLIPS_CHEATS_URL + util::formatApplicationId(tid) + "/" + bid).c_str(), headers); + json cheatsInfo = download::getRequest(CHEATSLIPS_CHEATS_URL + util::formatApplicationId(tid) + "/" + bid, headers); if(cheatsInfo.find("cheats") != cheatsInfo.end()) { for (const auto& p : cheatsInfo["cheats"].items()) { json cheat = p.value(); @@ -75,7 +75,7 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true) if(token.find("token") != token.end()) { headers.push_back("X-API-TOKEN: " + token["token"].get()); } - json cheatsInfo = download::getRequest(("https://www.cheatslips.com/api/v1/cheats/" + util::formatApplicationId(tid) + "/" + bid).c_str(), headers); + json cheatsInfo = download::getRequest("https://www.cheatslips.com/api/v1/cheats/" + util::formatApplicationId(tid) + "/" + bid, headers); if(cheatsInfo.find("cheats") != cheatsInfo.end()) { for (const auto& p : cheatsInfo["cheats"].items()) { if(std::find(ids.begin(), ids.end(), p.value()["id"]) != ids.end()) { @@ -177,7 +177,7 @@ std::string DownloadCheatsPage::GetBuilIDFromFile(uint64_t tid) { this->setFooterText("Game version: v" + std::to_string(v / 0x10000)); std::string version = std::to_string(v); - std::string versions_str = download::downloadPage(std::string(VERSIONS_DIRECTORY + util::formatApplicationId(tid) + ".json").c_str()); + std::string versions_str = download::downloadPage(VERSIONS_DIRECTORY + util::formatApplicationId(tid) + ".json"); json versions; if (json::accept(versions_str)) versions = json::parse(versions_str); else versions = json::object(); diff --git a/source/download_payload_page.cpp b/source/download_payload_page.cpp index 5b5b304..7143113 100644 --- a/source/download_payload_page.cpp +++ b/source/download_payload_page.cpp @@ -33,7 +33,7 @@ DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true) new ConfirmPage(stagedFrame, text) ); stagedFrame->addStage( - new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url, path](){download::downloadFile(url.c_str(), path.c_str(), OFF);}) + new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url, path](){download::downloadFile(url, path.c_str(), OFF);}) ); stagedFrame->addStage( new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true) diff --git a/source/extract.cpp b/source/extract.cpp index 677171f..f3e4e68 100644 --- a/source/extract.cpp +++ b/source/extract.cpp @@ -25,10 +25,10 @@ namespace extract { } } -void extract(const char * filename, const char* workingPath, int overwriteInis){ +void extract(const std::string& filename, const std::string& workingPath, int overwriteInis){ ProgressEvent::instance().reset(); ProgressEvent::instance().setStep(1); - chdir(workingPath); + chdir(workingPath.c_str()); std::set ignoreList = fs::readLineByLine(FILES_IGNORE); std::set::iterator it; zipper::Unzipper unzipper(filename); @@ -64,7 +64,7 @@ void extract(const char * filename, const char* workingPath, int overwriteInis){ else { unzipper.extractEntry(entries[i].name); if(entries[i].name.substr(0, 13) == "hekate_ctcaer") { - fs::copyFile(("/" + entries[i].name).c_str(), UPDATE_BIN_PATH); + fs::copyFile("/" + entries[i].name, UPDATE_BIN_PATH); } } } @@ -75,10 +75,10 @@ void extract(const char * filename, const char* workingPath, int overwriteInis){ ProgressEvent::instance().setStep(ProgressEvent::instance().getMax()); } -void extract(const char * filename, const char* workingPath, const char* toExclude){ +void extract(const std::string& filename, const std::string& workingPath, const std::string& toExclude){ ProgressEvent::instance().reset(); ProgressEvent::instance().setStep(1); - chdir(workingPath); + chdir(workingPath.c_str()); std::set ignoreList = fs::readLineByLine(FILES_IGNORE); ignoreList.insert(toExclude); std::set::iterator it; @@ -143,7 +143,7 @@ std::vector getInstalledTitlesNs(){ return titles; } -std::vector excludeTitles(const char* path, std::vector listedTitles){ +std::vector excludeTitles(const std::string& path, std::vector listedTitles){ std::vector titles; std::ifstream file(path); int total = 0; @@ -171,7 +171,7 @@ std::vector excludeTitles(const char* path, std::vector titles, CFW cfw, bool credits){ +void extractCheats(const std::string& zipPath, std::vector titles, CFW cfw, bool credits){ //TODO: REWRITE WITH SETS INSTEAD OF VECTORS ProgressEvent::instance().reset(); zipper::Unzipper unzipper(zipPath); @@ -263,7 +263,7 @@ void extractCheats(const char * zipPath, std::vector titles, CFW cf ProgressEvent::instance().setStep(ProgressEvent::instance().getMax()); } -void extractAllCheats(const char * zipPath, CFW cfw){ +void extractAllCheats(const std::string& zipPath, CFW cfw){ ProgressEvent::instance().reset(); zipper::Unzipper unzipper(zipPath); std::vector entries = unzipper.entries(); @@ -309,7 +309,7 @@ bool isBID(std::string bid) { return true; } -void writeTitlesToFile(std::set titles, const char* path){ +void writeTitlesToFile(std::set titles, const std::string& path){ std::ofstream updatedTitlesFile; std::set::iterator it = titles.begin(); updatedTitlesFile.open(path, std::ofstream::out | std::ofstream::trunc); diff --git a/source/fs.cpp b/source/fs.cpp index 2ea4c24..44cb395 100644 --- a/source/fs.cpp +++ b/source/fs.cpp @@ -8,6 +8,18 @@ namespace i18n = brls::i18n; using namespace i18n::literals; +namespace { + std::vector splitString(const std::string& s, char delimiter) { + std::vector tokens; + std::string token; + std::istringstream tokenStream(s); + while (std::getline(tokenStream, token, delimiter)) { + tokens.push_back(token); + } + return tokens; + } +} + namespace fs { int removeDir(const char* path) { @@ -18,23 +30,23 @@ namespace fs { return 0; } - nlohmann::json parseJsonFile(const char* path) { + nlohmann::ordered_json parseJsonFile(const std::string& path) { std::ifstream file(path); std::string fileContent((std::istreambuf_iterator(file) ), (std::istreambuf_iterator() )); - if(nlohmann::json::accept(fileContent)) return nlohmann::json::parse(fileContent); - else return nlohmann::json::object(); + if(nlohmann::ordered_json::accept(fileContent)) return nlohmann::ordered_json::parse(fileContent); + else return nlohmann::ordered_json::object(); } - void writeJsonToFile(nlohmann::json &data, const char* path) { + void writeJsonToFile(nlohmann::json &data, const std::string& path) { std::ofstream out(path); out << data.dump(4); out.close(); } - bool copyFile(const char *from, const char *to){ + bool copyFile(const std::string& from, const std::string& to){ std::ifstream src(from, std::ios::binary); std::ofstream dst(to, std::ios::binary); @@ -46,31 +58,38 @@ namespace fs { } void createTree(std::string path){ - std::string delimiter = "/"; - size_t pos = 0; - std::string token; - std::string directories(""); - while ((pos = path.find(delimiter)) != std::string::npos) { - token = path.substr(0, pos); - directories += token + "/"; - std::filesystem::create_directory(directories); - path.erase(0, pos + delimiter.length()); + std::string delimiter = "/"; + size_t pos = 0; + std::string token; + std::string directories(""); + while ((pos = path.find(delimiter)) != std::string::npos) { + token = path.substr(0, pos); + directories += token + "/"; + std::filesystem::create_directory(directories); + path.erase(0, pos + delimiter.length()); + } } -} - std::string copyFiles(const char* path) { - nlohmann::ordered_json toMove; - std::ifstream f(COPY_FILES_JSON); - f >> toMove; - f.close(); + std::string copyFiles(const std::string& path) { std::string error = ""; - for (auto it = toMove.begin(); it != toMove.end(); ++it) { - if(std::filesystem::exists(it.key())) { - createTree(std::string(std::filesystem::path(it.value().get()).parent_path()) + "/"); - copyFile(it.key().c_str(), it.value().get().c_str()); - } - else { - error += it.key() + "\n"; + if (std::filesystem::exists(path)) { + std::string str; + std::ifstream in(path); + if(in){ + while (std::getline(in, str)) + { + if(str.size() > 0) { + auto toMove = splitString(str, '|'); + if(std::filesystem::exists(toMove[0]) && toMove.size() > 1) { + copyFile(toMove[0], toMove[1]); + } + else { + error += toMove[0] + "\n"; + } + + } + } + in.close(); } } if(error == "") { @@ -82,7 +101,7 @@ namespace fs { return error; } - std::set readLineByLine(const char * path){ + std::set readLineByLine(const std::string& path){ std::set titles; std::string str; std::ifstream in(path); diff --git a/source/ntcp.cpp.meh b/source/ntcp.cpp.meh index c1d4e74..cd3fdbb 100644 --- a/source/ntcp.cpp.meh +++ b/source/ntcp.cpp.meh @@ -113,13 +113,13 @@ void serviceCleanup(void) timeExit(); } -void print(const char *msg) +void print(const std::string& msg) { puts(msg); consoleUpdate(NULL); } -void printWithArgs(const char *msg, ...) +void printWithArgs(const std::string& msg, ...) { va_list args; va_start(args, msg); @@ -132,7 +132,7 @@ void printWithArgs(const char *msg, ...) std::string syncTime() { - const char *server_name = "0.pool.ntp.org"; + const std::string& server_name = "0.pool.ntp.org"; const uint16_t port = 123; int sockfd = -1; std::stringstream out; diff --git a/source/payload_page.cpp b/source/payload_page.cpp index 1194519..723058e 100644 --- a/source/payload_page.cpp +++ b/source/payload_page.cpp @@ -29,7 +29,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true) if(CurrentCfw::running_cfw == CFW::ams){ listItem->registerAction("menus/payloads/set_reboot_payload"_i18n, brls::Key::X, [this, payload_path] { std::string res1; - if(fs::copyFile(payload_path.c_str(), REBOOT_PAYLOAD_PATH)){ + if(fs::copyFile(payload_path, REBOOT_PAYLOAD_PATH)){ res1 += "menus/payloads/copy_success"_i18n + payload_path + "menus/payloads/to"_i18n + std::string(REBOOT_PAYLOAD_PATH) + "'."; } @@ -48,7 +48,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true) } listItem->registerAction("menus/payloads/set_update_bin"_i18n, brls::Key::Y, [this, payload] { std::string res2; - if(fs::copyFile(payload.c_str(), UPDATE_BIN_PATH)){ + if(fs::copyFile(payload, UPDATE_BIN_PATH)){ res2 += "menus/payloads/copy_success"_i18n + payload + "menus/payloads/to"_i18n + std::string(UPDATE_BIN_PATH) + "'."; } else{ diff --git a/source/tools_tab.cpp b/source/tools_tab.cpp index 92aa60e..56d5874 100644 --- a/source/tools_tab.cpp +++ b/source/tools_tab.cpp @@ -156,8 +156,8 @@ ToolsTab::ToolsTab(std::string tag, bool erista) : brls::List() move->getClickEvent()->subscribe([&](brls::View* view){ chdir("/"); std::string error = ""; - if(std::filesystem::exists(COPY_FILES_JSON)){ - error = fs::copyFiles(COPY_FILES_JSON); + if(std::filesystem::exists(COPY_FILES_TXT)){ + error = fs::copyFiles(COPY_FILES_TXT); } else{ error = "menus/tools/batch_copy_config_not_found"_i18n; diff --git a/source/utils.cpp b/source/utils.cpp index 85fd4cf..9b74a9f 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -14,7 +14,7 @@ using namespace i18n::literals; namespace util { -bool isArchive(const char * path){ +bool isArchive(const std::string& path){ std::fstream file; std::string fileContent; if(std::filesystem::exists(path)){ @@ -30,32 +30,31 @@ void downloadArchive(std::string url, archiveType type){ AppletType at; switch(type){ case archiveType::sigpatches: - download::downloadFile(url.c_str(), SIGPATCHES_FILENAME, OFF); + download::downloadFile(url, SIGPATCHES_FILENAME, OFF); break; case archiveType::cheats: - download::downloadFile(url.c_str(), CHEATS_FILENAME, OFF); + download::downloadFile(url, CHEATS_FILENAME, OFF); break; case archiveType::fw: at = appletGetAppletType(); if (at == AppletType_Application || at == AppletType_SystemApplication) { - download::downloadFile(url.c_str(), FIRMWARE_FILENAME, OFF); + download::downloadFile(url, FIRMWARE_FILENAME, OFF); } else{ brls::Application::crash("menus/utils/fw_warning"_i18n); } break; case archiveType::app: - download::downloadFile(url.c_str(), APP_FILENAME, OFF); + download::downloadFile(url, APP_FILENAME, OFF); break; case archiveType::cfw: - download::downloadFile(url.c_str(), CFW_FILENAME, OFF); + download::downloadFile(url, CFW_FILENAME, OFF); break; case archiveType::ams_cfw: - download::downloadFile(url.c_str(), AMS_FILENAME, OFF); + download::downloadFile(url, AMS_FILENAME, OFF); } } - int showDialogBox(std::string text, std::string opt){ int dialogResult = -1; int result = -1; @@ -166,8 +165,8 @@ void extractArchive(archiveType type, std::string tag){ } break; } - if(std::filesystem::exists(COPY_FILES_JSON)) - fs::copyFiles(COPY_FILES_JSON); + if(type == archiveType::ams_cfw || type == archiveType::cfw) + fs::copyFiles(COPY_FILES_TXT); } std::string formatListItemTitle(const std::string &str, size_t maxScore) { @@ -214,7 +213,7 @@ void shutDown(bool reboot){ bpcExit(); } -std::string getLatestTag(const char *url){ +std::string getLatestTag(const std::string& url){ nlohmann::json tag = download::getRequest(url, {"accept: application/vnd.github.v3+json"}); if(tag.find("tag_name") != tag.end()) return tag["tag_name"]; @@ -222,14 +221,14 @@ std::string getLatestTag(const char *url){ return ""; } -void saveVersion(std::string version, const char* path){ +void saveVersion(std::string version, const std::string& path){ std::fstream newVersion; newVersion.open(path, std::fstream::out | std::fstream::trunc); newVersion << version << std::endl; newVersion.close(); } -std::string readVersion(const char* path){ +std::string readVersion(const std::string& path){ std::fstream versionFile; std::string version = "0"; if(std::filesystem::exists(path)){ @@ -262,7 +261,7 @@ bool isErista() { } }; -void removeSysmodulesFlags(const char * directory) { +void removeSysmodulesFlags(const std::string& directory) { for (const auto & e : std::filesystem::recursive_directory_iterator(directory)) { if(e.path().string().find("boot2.flag") != std::string::npos) { std::filesystem::remove(e.path());