1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-12-28 02:16:03 +00:00

changed way of copying files after an install

This commit is contained in:
flb 2021-05-22 18:10:34 +02:00
parent 0c4fd67e08
commit 6c13a2f817
19 changed files with 130 additions and 111 deletions

3
copy_files.txt Normal file
View file

@ -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

View file

@ -5,22 +5,22 @@
namespace JC {
int setColor(std::vector<int> colors);
int backupToJSON(nlohmann::json &profiles, const char* path);
std::vector<std::pair<std::string, std::vector<int>>> getProfiles(const char* path);
int backupToJSON(nlohmann::json &profiles, const std::string& path);
std::vector<std::pair<std::string, std::vector<int>>> getProfiles(const std::string& path);
void changeJCColor(std::vector<int> values);
nlohmann::json backupProfile();
void backupJCColor(const char* path);
void backupJCColor(const std::string& path);
}
namespace PC {
int setColor(std::vector<int> colors);
int backupToJSON(nlohmann::json &profiles, const char* path);
std::vector<std::pair<std::string, std::vector<int>>> getProfiles(const char* path);
int backupToJSON(nlohmann::json &profiles,const std::string& path);
std::vector<std::pair<std::string, std::vector<int>>> getProfiles(const std::string& path);
void changePCColor(std::vector<int> values);
nlohmann::json backupProfile();
void backupPCColor(const char* path);
void backupPCColor(const std::string& path);
}

View file

@ -81,7 +81,7 @@ 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";

View file

@ -7,11 +7,11 @@ constexpr int OFF = 0;
namespace download {
std::vector<std::uint8_t> downloadFile(const char *url, const char *output = "", int api = OFF);
std::vector<std::pair<std::string, std::string>> getLinks(const char *url);
std::string fetchTitle(const char *url);
std::string downloadPage(const char* url, std::vector<std::string> headers = {}, std::string body = "");
std::vector<std::uint8_t> downloadPageBinary(const char* url, std::vector<std::string> headers = {}, std::string body = "");
nlohmann::ordered_json getRequest(std::string url, std::vector<std::string> headers = {}, std::string body = "");
std::vector<std::uint8_t> downloadFile(const std::string& url, const char* output = "", int api = OFF);
std::vector<std::pair<std::string, std::string>> getLinks(const std::string& url);
std::string fetchTitle(const std::string& url);
std::string downloadPage(const std::string& url, std::vector<std::string> headers = {}, std::string body = "");
std::vector<std::uint8_t> downloadPageBinary(const std::string& url, std::vector<std::string> headers = {}, std::string body = "");
nlohmann::ordered_json getRequest(const std::string& url, std::vector<std::string> headers = {}, std::string body = "");
}

View file

@ -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<std::string> getInstalledTitlesNs();
std::vector<std::string> excludeTitles(const char* path, std::vector<std::string> listedTitles);
void writeTitlesToFile(std::set<std::string> titles, const char* path);
void extractCheats(const char * zipPath, std::vector<std::string> titles, CFW cfw, bool credits = false);
void extractAllCheats(const char * zipPath, CFW cfw);
std::vector<std::string> excludeTitles(const std::string& path, std::vector<std::string> listedTitles);
void writeTitlesToFile(std::set<std::string> titles, const std::string& path);
void extractCheats(const std::string& zipPath, std::vector<std::string> titles, CFW cfw, bool credits = false);
void extractAllCheats(const std::string& zipPath, CFW cfw);
void removeCheats(CFW cfw);
bool isBID(std::string bid);

View file

@ -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<std::string> readLineByLine(const char * path);
std::set<std::string> readLineByLine(const std::string& path);
}

View file

@ -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);
}

View file

@ -16,7 +16,7 @@ AmsTab::AmsTab(const bool erista) :
{
std::vector<std::pair<std::string, std::string>> 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);

View file

@ -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<std::pair<std::string, std::vector<int>>> getProfiles(const char* path){
std::vector<std::pair<std::string, std::vector<int>>> getProfiles(const std::string& path){
std::vector<std::pair<std::string, std::vector<int>>> 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<int> oldBackups;
@ -266,7 +266,7 @@ namespace PC {
}
std::vector<std::pair<std::string, std::vector<int>>> getProfiles(const char* path){
std::vector<std::pair<std::string, std::vector<int>>> getProfiles(const std::string& path){
std::vector<std::pair<std::string, std::vector<int>>> 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();

View file

@ -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);

View file

@ -100,7 +100,7 @@ namespace download {
}
std::vector<std::uint8_t> downloadFile(const char *url, const char *output, int api)
std::vector<std::uint8_t> downloadFile(const std::string& url, const char* output, int api)
{
ProgressEvent::instance().reset();
CURL *curl = curl_easy_init();
@ -116,7 +116,7 @@ std::vector<std::uint8_t> 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<std::uint8_t> 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<std::string> headers, std::string body){
std::string downloadPage(const std::string& url, std::vector<std::string> 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<std::string> 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<std::string> headers, std:
return res;
}
std::vector<std::uint8_t> downloadPageBinary(const char* url, std::vector<std::string> headers, std::string body){
std::vector<std::uint8_t> downloadPageBinary(const std::string& url, std::vector<std::string> headers, std::string body){
CURL *curl_handle;
struct MemoryStruct chunk;
struct curl_slist *list = NULL;
@ -260,15 +260,15 @@ std::vector<std::uint8_t> downloadPageBinary(const char* url, std::vector<std::s
return res;
}
nlohmann::ordered_json getRequest(std::string url, std::vector<std::string> headers, std::string body) {
nlohmann::ordered_json getRequest(const std::string& url, std::vector<std::string> 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<std::pair<std::string, std::string>> getLinks(const char *url) {
std::vector<std::pair<std::string, std::string>> getLinks(const std::string& url) {
std::string request;
request = downloadPage(url);

View file

@ -31,7 +31,7 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true)
if(bid != "") {
std::vector<std::string> 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<std::string>());
}
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();

View file

@ -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)

View file

@ -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<std::string> ignoreList = fs::readLineByLine(FILES_IGNORE);
std::set<std::string>::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<std::string> ignoreList = fs::readLineByLine(FILES_IGNORE);
ignoreList.insert(toExclude);
std::set<std::string>::iterator it;
@ -143,7 +143,7 @@ std::vector<std::string> getInstalledTitlesNs(){
return titles;
}
std::vector<std::string> excludeTitles(const char* path, std::vector<std::string> listedTitles){
std::vector<std::string> excludeTitles(const std::string& path, std::vector<std::string> listedTitles){
std::vector<std::string> titles;
std::ifstream file(path);
int total = 0;
@ -171,7 +171,7 @@ std::vector<std::string> excludeTitles(const char* path, std::vector<std::string
return diff;
}
void extractCheats(const char * zipPath, std::vector<std::string> titles, CFW cfw, bool credits){
void extractCheats(const std::string& zipPath, std::vector<std::string> 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<std::string> 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<zipper::ZipEntry> entries = unzipper.entries();
@ -309,7 +309,7 @@ bool isBID(std::string bid) {
return true;
}
void writeTitlesToFile(std::set<std::string> titles, const char* path){
void writeTitlesToFile(std::set<std::string> titles, const std::string& path){
std::ofstream updatedTitlesFile;
std::set<std::string>::iterator it = titles.begin();
updatedTitlesFile.open(path, std::ofstream::out | std::ofstream::trunc);

View file

@ -8,6 +8,18 @@
namespace i18n = brls::i18n;
using namespace i18n::literals;
namespace {
std::vector<std::string> splitString(const std::string& s, char delimiter) {
std::vector<std::string> 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<char>(file) ),
(std::istreambuf_iterator<char>() ));
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);
@ -58,19 +70,26 @@ namespace fs {
}
}
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<std::string>()).parent_path()) + "/");
copyFile(it.key().c_str(), it.value().get<std::string>().c_str());
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 += it.key() + "\n";
error += toMove[0] + "\n";
}
}
}
in.close();
}
}
if(error == "") {
@ -82,7 +101,7 @@ namespace fs {
return error;
}
std::set<std::string> readLineByLine(const char * path){
std::set<std::string> readLineByLine(const std::string& path){
std::set<std::string> titles;
std::string str;
std::ifstream in(path);

View file

@ -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;

View file

@ -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{

View file

@ -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;

View file

@ -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());