From 0f76f7a39d8706b583ecea6ac6963f3b0d6d2e71 Mon Sep 17 00:00:00 2001 From: flb Date: Sun, 17 Jan 2021 18:26:20 +0100 Subject: [PATCH] (hopefully) increased copying reliability --- .github/workflows/main.yml | 4 ++++ .gitignore | 3 ++- Makefile | 2 +- README.md | 2 +- resources/i18n/en-US/menus.json | 6 +++-- source/changelog_page.cpp | 3 +++ source/payload_page.cpp | 39 +++++++++++++++++++++------------ source/utils.cpp | 6 ++--- 8 files changed, 43 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f51348..cd18c31 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,10 @@ jobs: - name: Update repo. run: | git submodule update --init --recursive + + - name: Update libnx to 4.0. + run: | + pacman -S libnx>=4.0 - name: Building aio-switch-updater run: | diff --git a/.gitignore b/.gitignore index ec16897..c597b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -.vscode/settings.json +.vscode/ +!.vscode/c_cpp_properties.json build/ screenshots/ switch/ diff --git a/Makefile b/Makefile index ed3a085..76fc536 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ DATA := data INCLUDES := include lib/zipper/include APP_TITLE := All-in-One Switch Updater APP_AUTHOR := HamletDuFromage -APP_VERSION := 1.4.1 +APP_VERSION := 1.4.2 TARGET := $(notdir $(CURDIR))-v$(APP_VERSION) ROMFS := resources diff --git a/README.md b/README.md index d7ce974..1d38f82 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Downloads and extracts daily-updated cheat code. The program will only extract c - Reboot to specific payload. - Download payloads to `/bootloader/payloads`. - Change software color scheme of Joy-Cons. Additional color profiles can be found in the releases and should be copied to `config/aio-switch-updater/jc_profiles.json`. -- Change software color scheme of Pro controllers (has to be paired as Player 1). Additional color profiles can be found in the releases and should be copied to `config/aio-switch-updater/pc_profiles.json`. +- Change software color scheme of Pro Controllers (has to be paired as Player 1). Additional color profiles can be found in the releases and should be copied to `config/aio-switch-updater/pc_profiles.json`. - View which of your games got cheat codes from the app. - Launch the Switch's web browser. - Edit internet settings (DNS, IP address, MTU, etc). Add you own configs to `config/aio-switch-updater/internet.json`. You can find a template in the root of the repo. diff --git a/resources/i18n/en-US/menus.json b/resources/i18n/en-US/menus.json index a6428bc..2f3f446 100644 --- a/resources/i18n/en-US/menus.json +++ b/resources/i18n/en-US/menus.json @@ -52,6 +52,8 @@ "v1_4_0_text": "\uE016 Added possibility to use pre-set network settings. Add your own in `config/aio-switch-updater/internet.json.\n\uE016 Added web browser.", "v1_4_1": "v1.4.1", "v1_4_1_text": "\uE016 Fixed misleading display in internet settings page.", + "v1_4_2": "v1.4.2", + "v1_4_2_text": "\uE016 (hopefully) fixed unreliable copy of payloads", "Ok_button": "Ok", "cheats_page.cpp":"", @@ -105,7 +107,7 @@ "pro_con": "Pro-Con color swapper", "pc_you_can" : "You can change the internal color of your Pro Controller. Make sure it's set to Player 1.", - "pc_color": "Pro controller color swapper", + "pc_color": "Pro Controller color swapper", "pc_backing": "Backing up the color profile", "pc_all_done": "All done! You may need to turn your controller on and off for the change to take effect", @@ -156,7 +158,7 @@ "tools_tab.cpp":"", "tool_cheats": "Cheats menu", "tool_change": "Change the Joy-Cons color", - "tool_change_procon": "Change the Pro controller color", + "tool_change_procon": "Change the Pro Controller color", "tool_download": "Dowload payloads to ", "tool_inject": "Inject payload", "tool_update": "Update the app (v", diff --git a/source/changelog_page.cpp b/source/changelog_page.cpp index f4337e9..b44e5f5 100644 --- a/source/changelog_page.cpp +++ b/source/changelog_page.cpp @@ -64,6 +64,9 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true) verTitles.push_back("menus/v1_4_1"_i18n ); changes.push_back("menus/v1_4_1_text"_i18n ); + verTitles.push_back("menus/v1_4_2"_i18n ); + changes.push_back("menus/v1_4_2_text"_i18n ); + int nbVersions = verTitles.size(); items.reserve(nbVersions); for(int i = nbVersions -1 ; i >= 0; i--){ diff --git a/source/payload_page.cpp b/source/payload_page.cpp index 307eedb..197f091 100644 --- a/source/payload_page.cpp +++ b/source/payload_page.cpp @@ -25,28 +25,39 @@ PayloadPage::PayloadPage() : AppletFrame(true, true) }); if(cfw == ams){ items[i]->registerAction("menus/payload_set"_i18n , brls::Key::X, [this, payload] { + std::string res1; if(R_SUCCEEDED(CopyFile(payload.c_str(), REBOOT_PAYLOAD_PATH))){ - brls::Dialog* dialog = new brls::Dialog("menus/payload_success"_i18n + payload + "menus/payload_to"_i18n + std::string(REBOOT_PAYLOAD_PATH) + "'."); - brls::GenericEvent::Callback callback = [dialog](brls::View* view) { - dialog->close(); - }; - dialog->addButton("menus/payload_ok"_i18n , callback); - dialog->setCancelable(true); - dialog->open(); + res1 += "menus/payload_success"_i18n + payload + "menus/payload_to"_i18n + std::string(REBOOT_PAYLOAD_PATH) + "'."; + } + else{ + res1 += "Failed."; + } + brls::Dialog* dialog = new brls::Dialog(res1); + brls::GenericEvent::Callback callback = [dialog](brls::View* view) { + dialog->close(); + }; + dialog->addButton("menus/payload_ok"_i18n , callback); + dialog->setCancelable(true); + dialog->open(); return true; }); } items[i]->registerAction("menus/payload_set_up"_i18n , brls::Key::Y, [this, payload] { + std::string res2; if(R_SUCCEEDED(CopyFile(payload.c_str(), UPDATE_BIN_PATH))){ - brls::Dialog* dialog = new brls::Dialog("menus/payload_success"_i18n + payload + "menus/payload_to"_i18n + std::string(UPDATE_BIN_PATH) + "'."); - brls::GenericEvent::Callback callback = [dialog](brls::View* view) { - dialog->close(); - }; - dialog->addButton("menus/payload_ok"_i18n , callback); - dialog->setCancelable(true); - dialog->open(); + res2 += "menus/payload_success"_i18n + payload + "menus/payload_to"_i18n + std::string(UPDATE_BIN_PATH) + "'."; } + else{ + res2 += "Failed."; + } + brls::Dialog* dialog = new brls::Dialog(res2); + brls::GenericEvent::Callback callback = [dialog](brls::View* view) { + dialog->close(); + }; + dialog->addButton("menus/payload_ok"_i18n , callback); + dialog->setCancelable(true); + dialog->open(); return true; }); list->addView(items[i]); diff --git a/source/utils.cpp b/source/utils.cpp index 697d7ae..dc6d4c9 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -299,9 +299,9 @@ Result CopyFile(const char src_path[FS_MAX_PATH], const char dest_path[FS_MAX_PA fsFileClose(&src_handle); return ret; } - - if (!std::filesystem::exists(dest_path)) - fsFsCreateFile(fs, dest_path, size, 0); + + std::filesystem::remove(dest_path); + fsFsCreateFile(fs, dest_path, size, 0); ret = fsFsOpenFile(fs, dest_path, FsOpenMode_Write, &dest_handle); if (R_FAILED(ret)){