| 470 | } |
| 471 | |
| 472 | void BrowserLayout::OnDirectorySelected(const std::string &item, const std::string &full_item, const std::string &pres_full_item) { |
| 473 | const auto ipc_full_item = this->cur_exp->RemoveMountName(full_item); |
| 474 | AmsSuUpdateInformation update_info; |
| 475 | auto rc = amssuGetUpdateInformation(ipc_full_item.c_str(), &update_info); |
| 476 | const auto is_valid_update = R_SUCCEEDED(rc); |
| 477 | |
| 478 | const auto files = this->cur_exp->GetFiles(full_item); |
| 479 | std::vector<std::string> nsps; |
| 480 | for(const auto &file: files) { |
| 481 | if(g_Settings.json_settings.fs.value().ignore_hidden_files.value() && IsHiddenContent(file)) { |
| 482 | continue; |
| 483 | } |
| 484 | |
| 485 | const auto path = full_item + "/" + file; |
| 486 | const auto ext = LowerCaseString(fs::GetExtension(path)); |
| 487 | if(ext == "nsp") { |
| 488 | nsps.push_back(file); |
| 489 | } |
| 490 | } |
| 491 | std::vector<std::string> extra_options = { cfg::Strings.GetString(281) }; |
| 492 | if(!nsps.empty()) { |
| 493 | extra_options.push_back(cfg::Strings.GetString(282)); |
| 494 | } |
| 495 | extra_options.push_back(cfg::Strings.GetString(18)); |
| 496 | |
| 497 | auto msg = cfg::Strings.GetString(134); |
| 498 | if(g_Settings.json_settings.fs.value().compute_directory_sizes.value()) { |
| 499 | // This can be pretty slow, so only do it if the user wants it |
| 500 | msg += "\n\n" + cfg::Strings.GetString(237) + " " + fs::FormatSize(this->cur_exp->GetDirectorySize(full_item)); |
| 501 | } |
| 502 | const auto option_1 = g_MainApplication->DisplayDialog(cfg::Strings.GetString(135), msg, { cfg::Strings.GetString(415), cfg::Strings.GetString(73), cfg::Strings.GetString(74), cfg::Strings.GetString(75), cfg::Strings.GetString(280), cfg::Strings.GetString(18) }, true); |
| 503 | switch(option_1) { |
| 504 | case 0: { |
| 505 | if(is_valid_update) { |
| 506 | std::string update_msg = ""; |
| 507 | const auto version_str = std::to_string((update_info.version >> 26) & 0x1F) + "." + std::to_string((update_info.version >> 20) & 0x1F) + "." + std::to_string((update_info.version >> 16) & 0xF); |
| 508 | update_msg += " - " + cfg::Strings.GetString(417) + " " + version_str + "\n\n"; |
| 509 | update_msg += " - " + cfg::Strings.GetString(418) + " " + (update_info.exfat_supported ? cfg::Strings.GetString(111) : cfg::Strings.GetString(112)); |
| 510 | |
| 511 | const auto option_2 = g_MainApplication->DisplayDialog(cfg::Strings.GetString(416), update_msg, { cfg::Strings.GetString(419), cfg::Strings.GetString(18) }, true); |
| 512 | if(option_2 == 0) { |
| 513 | AmsSuUpdateValidationInfo update_validation_info; |
| 514 | Result validate_rc; |
| 515 | Result validate_exfat_rc; |
| 516 | rc = amssuValidateUpdate(ipc_full_item.c_str(), &update_validation_info, &validate_rc, &validate_exfat_rc); |
| 517 | if(R_SUCCEEDED(rc) && R_SUCCEEDED(validate_rc) && R_SUCCEEDED(validate_exfat_rc)) { |
| 518 | const auto option_3 = g_MainApplication->DisplayDialog(cfg::Strings.GetString(420), cfg::Strings.GetString(421), { cfg::Strings.GetString(423), cfg::Strings.GetString(18) }, true); |
| 519 | if(option_3 == 0) { |
| 520 | const auto option_4 = g_MainApplication->DisplayDialog(cfg::Strings.GetString(424), cfg::Strings.GetString(425), { cfg::Strings.GetString(111), cfg::Strings.GetString(112), cfg::Strings.GetString(18) }, true); |
| 521 | if((option_4 == 0) || (option_4 == 1)) { |
| 522 | const auto with_exfat = option_4 == 0; |
| 523 | SetSysFirmwareVersion fw_ver; |
| 524 | GLEAF_RC_ASSERT(setsysGetFirmwareVersion(&fw_ver)); |
| 525 | g_MainApplication->LoadCommonIconMenuData(true, cfg::Strings.GetString(424), CommonIconKind::Update, std::string(fw_ver.display_version) + " → " + version_str + "..."); |
| 526 | g_MainApplication->ShowLayout(g_MainApplication->GetUpdateInstallLayout()); |
| 527 | g_MainApplication->GetUpdateInstallLayout()->InstallUpdate(ipc_full_item, with_exfat); |
| 528 | } |
| 529 | } |
no test coverage detected