| 50 | } |
| 51 | |
| 52 | void ContentExportLayout::StartExport(const cnt::Application &app, const u32 cnt_i, const bool has_tik) { |
| 53 | const auto &cnt_status = app.meta_status_list.at(cnt_i); |
| 54 | const auto &cnts = app.contents.at(cnt_i); |
| 55 | const auto cnt_storage_id = static_cast<NcmStorageId>(cnt_status.storageID); |
| 56 | const auto format_app_id = util::FormatApplicationId(cnt_status.application_id); |
| 57 | |
| 58 | g_MainApplication->LoadMenuData(true, cfg::Strings.GetString(505), GetApplicationIcon(app.record.id), cfg::Strings.GetString(359) + ": " + app.cache.display_name + " (" + cnt::GetContentMetaTypeName(static_cast<NcmContentMetaType>(cnt_status.meta_type)) + ", " + format_app_id + ")"); |
| 59 | |
| 60 | ScopeGuard on_exit([&]() { |
| 61 | g_MainApplication->ReturnToParentLayout(); |
| 62 | }); |
| 63 | |
| 64 | EnsureDirectories(); |
| 65 | g_MainApplication->CallForRender(); |
| 66 | |
| 67 | g_MainApplication->ClearLayout(g_MainApplication->GetContentExportLayout()); |
| 68 | this->content_info_texts.clear(); |
| 69 | this->content_p_bars.clear(); |
| 70 | this->Add(this->speed_info_text); |
| 71 | |
| 72 | auto sd_exp = fs::GetSdCardExplorer(); |
| 73 | const auto out_dir = sd_exp->MakeAbsolute(GLEAF_PATH_EXPORT_TITLE_DIR "/" + format_app_id); |
| 74 | sd_exp->CreateDirectory(out_dir); |
| 75 | this->speed_info_text->SetText(cfg::Strings.GetString(192)); |
| 76 | g_MainApplication->CallForRender(); |
| 77 | if(has_tik) { |
| 78 | expt::ExportTicketCert(cnt_status.application_id, true); |
| 79 | } |
| 80 | this->speed_info_text->SetText(cfg::Strings.GetString(193)); |
| 81 | g_MainApplication->CallForRender(); |
| 82 | |
| 83 | NcmContentStorage cnt_storage; |
| 84 | auto rc = ncmOpenContentStorage(&cnt_storage, cnt_storage_id); |
| 85 | if(R_FAILED(rc)) { |
| 86 | HandleResult(rc::goldleaf::ResultUnableToLocateContents, cfg::Strings.GetString(198)); |
| 87 | return; |
| 88 | } |
| 89 | ScopeGuard on_exit_1([&]() { |
| 90 | ncmContentStorageClose(&cnt_storage); |
| 91 | }); |
| 92 | |
| 93 | NcmContentMetaDatabase cnt_meta_db; |
| 94 | rc = ncmOpenContentMetaDatabase(&cnt_meta_db, cnt_storage_id); |
| 95 | if(R_FAILED(rc)) { |
| 96 | HandleResult(rc::goldleaf::ResultUnableToLocateContents, cfg::Strings.GetString(198)); |
| 97 | return; |
| 98 | } |
| 99 | ScopeGuard on_exit_2([&]() { |
| 100 | ncmContentMetaDatabaseClose(&cnt_meta_db); |
| 101 | }); |
| 102 | |
| 103 | std::vector<std::pair<bool, NcmContentId>> export_cnts; |
| 104 | auto is_any_meta = false; |
| 105 | for(u32 i = 0; i < cnt::MaxContentCount; i++) { |
| 106 | if(cnts.cnt_ids[i].has_value()) { |
| 107 | const auto is_meta = static_cast<NcmContentType>(i) == NcmContentType_Meta; |
| 108 | export_cnts.push_back({ is_meta, cnts.cnt_ids[i].value() }); |
| 109 | if(is_meta) { |
no test coverage detected