From 9a59359bd0ba3a436a9d9cf46c6db3377ab8fb89 Mon Sep 17 00:00:00 2001 From: Huntereb Date: Fri, 8 Nov 2019 11:02:25 -0500 Subject: [PATCH] Tell how many nsps installed, and which ones failed to install --- source/netInstall.cpp | 15 ++++++++------- source/nspInstall.cpp | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/source/netInstall.cpp b/source/netInstall.cpp index 4de2336..3805ee3 100755 --- a/source/netInstall.cpp +++ b/source/netInstall.cpp @@ -121,14 +121,15 @@ namespace netInstStuff{ FsStorageId m_destStorageId = FsStorageId_SdCard; if (ourStorage) m_destStorageId = FsStorageId_NandUser; + unsigned int urlItr; try { - for (unsigned int i = 0; i < ourUrlList.size(); i++) { - inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(inst::util::formatUrlString(ourUrlList[i]), 48, true)); + for (urlItr = 0; urlItr < ourUrlList.size(); urlItr++) { + inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(inst::util::formatUrlString(ourUrlList[urlItr]), 48, true)); - tin::install::nsp::HTTPNSP httpNSP(ourUrlList[i]); + tin::install::nsp::HTTPNSP httpNSP(ourUrlList[urlItr]); - printf("%s %s\n", "Install request from", ourUrlList[i].c_str()); + printf("%s %s\n", "Install request from", ourUrlList[urlItr].c_str()); tin::install::nsp::RemoteNSPInstall install(m_destStorageId, inst::config::ignoreReqVers, &httpNSP); printf("%s\n", "Preparing installation"); @@ -142,9 +143,9 @@ namespace netInstStuff{ printf("Failed to install"); printf("%s", e.what()); fprintf(stdout, "%s", e.what()); - inst::ui::setInstInfoText("Failed to install"); + inst::ui::setInstInfoText("Failed to install " + inst::util::shortenString(ourUrlList[urlItr].erase(0, 6), 48, true)); inst::ui::setInstBarPerc(0); - inst::ui::mainApp->CreateShowDialog("Failed to install!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); + inst::ui::mainApp->CreateShowDialog("Failed to install " + inst::util::shortenString(ourUrlList[urlItr].erase(0, 6), 48, true) + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); nspInstalled = false; } @@ -156,7 +157,7 @@ namespace netInstStuff{ if(nspInstalled) { inst::ui::setInstInfoText("Install complete"); inst::ui::setInstBarPerc(100); - if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog("Selected files installed!", nspInstStuff::finishedMessage(), {"OK"}, true); + if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true); else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(inst::util::formatUrlString(ourUrlList[0]), 48, true) + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true); } diff --git a/source/nspInstall.cpp b/source/nspInstall.cpp index 07068f7..13956ec 100755 --- a/source/nspInstall.cpp +++ b/source/nspInstall.cpp @@ -90,21 +90,22 @@ namespace nspInstStuff { std::vector oldNamesOfFiles = {}; if (whereToInstall) m_destStorageId = FsStorageId_NandUser; + unsigned int nspItr; try { - for (unsigned int i = 0; i < ourNspList.size(); i++) { - inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(ourNspList[i].string().erase(0, 6), 48, true)); + for (nspItr = 0; nspItr < ourNspList.size(); nspItr++) { + inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(ourNspList[nspItr].string().erase(0, 6), 48, true)); - if (ourNspList[i].extension() == ".nsz") { - oldNamesOfFiles.push_back(ourNspList[i]); - std::string newfilename = ourNspList[i].string().substr(0, ourNspList[i].string().find_last_of('.'))+"_temp.nsp"; - rename(ourNspList[i], newfilename); + if (ourNspList[nspItr].extension() == ".nsz") { + oldNamesOfFiles.push_back(ourNspList[nspItr]); + std::string newfilename = ourNspList[nspItr].string().substr(0, ourNspList[nspItr].string().find_last_of('.'))+"_temp.nsp"; + rename(ourNspList[nspItr], newfilename); filesToBeRenamed.push_back(newfilename); - ourNspList[i] = newfilename; + ourNspList[nspItr] = newfilename; } - std::string path = "@Sdcard://" + ourNspList[i].string().erase(0, 6); + std::string path = "@Sdcard://" + ourNspList[nspItr].string().erase(0, 6); nx::fs::IFileSystem fileSystem; fileSystem.OpenFileSystemWithId(path, FsFileSystemType_ApplicationPackage, 0); @@ -123,9 +124,9 @@ namespace nspInstStuff { printf("Failed to install"); printf("%s", e.what()); fprintf(stdout, "%s", e.what()); - inst::ui::setInstInfoText("Failed to install"); + inst::ui::setInstInfoText("Failed to install " + inst::util::shortenString(ourNspList[nspItr].string().erase(0, 6), 48, true)); inst::ui::setInstBarPerc(0); - inst::ui::mainApp->CreateShowDialog("Failed to install!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); + inst::ui::mainApp->CreateShowDialog("Failed to install " + inst::util::shortenString(ourNspList[nspItr].string().erase(0, 6), 48, true) + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); nspInstalled = false; } @@ -141,12 +142,12 @@ namespace nspInstStuff { inst::ui::setInstBarPerc(100); if (ourNspList.size() > 1) { if (inst::config::deletePrompt) { - if(inst::ui::mainApp->CreateShowDialog("Selected files installed! Delete them from the SD card?", "NSP and NSZ files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) { + if(inst::ui::mainApp->CreateShowDialog(std::to_string(ourNspList.size()) + " files installed successfully! Delete them from the SD card?", "NSP and NSZ files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) { for (long unsigned int i = 0; i < ourNspList.size(); i++) { if (std::filesystem::exists(ourNspList[i])) std::filesystem::remove(ourNspList[i]); } } - } else inst::ui::mainApp->CreateShowDialog("Selected files installed!", nspInstStuff::finishedMessage(), {"OK"}, true); + } else inst::ui::mainApp->CreateShowDialog(std::to_string(ourNspList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true); } else { if (inst::config::deletePrompt) { if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourNspList[0].string().erase(0, 6), 48, true) + " installed! Delete it from the SD card?", "NSP and NSZ files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) if (std::filesystem::exists(ourNspList[0])) std::filesystem::remove(ourNspList[0]);