| 67 | } |
| 68 | |
| 69 | void SettingsLayout::ExportUpdateToDirectory(const std::string &fw_path, const SetSysFirmwareVersion &fw_ver) { |
| 70 | auto sd_exp = fs::GetSdCardExplorer(); |
| 71 | auto exp = fs::GetNANDSystemExplorer(); |
| 72 | this->options_menu->SetVisible(false); |
| 73 | this->fw_export_p_bar->SetVisible(true); |
| 74 | std::string fw_display_version = fw_ver.display_version; |
| 75 | g_MainApplication->LoadCommonIconMenuData(true, cfg::Strings.GetString(43), CommonIconKind::Settings, cfg::Strings.GetString(359) + " " + fw_display_version + "..."); |
| 76 | const auto out_dir = sd_exp->FullPathFor(GLEAF_PATH_EXPORT_UPDATE_DIR "/" + fw_display_version); |
| 77 | sd_exp->DeleteDirectory(out_dir); |
| 78 | exp->CopyDirectoryProgress(fw_path, out_dir, [&](const size_t total_size) { |
| 79 | this->fw_export_p_bar->SetMaxProgress(total_size); |
| 80 | }, [](const size_t file_size, const std::string &old_file, const std::string &new_file) { |
| 81 | // ... |
| 82 | }, [&](const size_t cur_rw_size) { |
| 83 | this->fw_export_p_bar->IncrementProgress(cur_rw_size); |
| 84 | g_MainApplication->CallForRender(); |
| 85 | }); |
| 86 | // Rename meta NCAs to .cnmt.nca so that this update is valid for Daybreak |
| 87 | const auto files = sd_exp->GetFiles(out_dir); |
| 88 | for(const auto &file: files) { |
| 89 | const auto original_nca = "@SystemContent://registered/" + file; |
| 90 | FsFileSystem nca_fs; |
| 91 | const auto rc = fsOpenFileSystemWithId(&nca_fs, 0, FsFileSystemType_ContentMeta, original_nca.c_str(), FsContentAttributes_All); |
| 92 | if(R_SUCCEEDED(rc)) { |
| 93 | // Is a meta NCA |
| 94 | const auto out_nca_path = out_dir + "/" + file; |
| 95 | const auto out_nca_path_noext = out_nca_path.substr(0, out_nca_path.length() - __builtin_strlen("nca")); |
| 96 | const auto out_cnmt_nca_path = out_nca_path_noext + "cnmt.nca"; |
| 97 | sd_exp->RenameFile(out_nca_path, out_cnmt_nca_path); |
| 98 | } |
| 99 | } |
| 100 | g_MainApplication->PopMenuData(); |
| 101 | this->options_menu->SetVisible(true); |
| 102 | this->fw_export_p_bar->SetVisible(false); |
| 103 | g_MainApplication->ShowNotification(cfg::Strings.GetString(358) + " '" + out_dir + "'."); |
| 104 | } |
| 105 | |
| 106 | void SettingsLayout::HandleUpdate(const std::string &fw_path_base, const SetSysFirmwareVersion &fw_ver) { |
| 107 | const auto option = g_MainApplication->DisplayDialog(cfg::Strings.GetString(360), cfg::Strings.GetString(361), { cfg::Strings.GetString(377), cfg::Strings.GetString(18)}, true); |
nothing calls this directly
no test coverage detected