| 99 | } |
| 100 | |
| 101 | void CafeTitleList::StoreCacheFile() |
| 102 | { |
| 103 | cemu_assert_debug(sTLInitialized); |
| 104 | if (sTLCacheFilePath.empty()) |
| 105 | return; |
| 106 | std::unique_lock _lock(sTLMutex); |
| 107 | |
| 108 | pugi::xml_document doc; |
| 109 | auto declarationNode = doc.append_child(pugi::node_declaration); |
| 110 | declarationNode.append_attribute("version") = "1.0"; |
| 111 | declarationNode.append_attribute("encoding") = "UTF-8"; |
| 112 | auto title_list_node = doc.append_child("title_list"); |
| 113 | |
| 114 | for (auto& tiIt : sTLList) |
| 115 | { |
| 116 | TitleInfo::CachedInfo info = tiIt->MakeCacheEntry(); |
| 117 | auto titleInfoNode = title_list_node.append_child("title"); |
| 118 | titleInfoNode.append_attribute("titleId").set_value(fmt::format("{:016x}", info.titleId).c_str()); |
| 119 | titleInfoNode.append_attribute("version").set_value(fmt::format("{:}", info.titleVersion).c_str()); |
| 120 | titleInfoNode.append_attribute("sdk_version").set_value(fmt::format("{:}", info.sdkVersion).c_str()); |
| 121 | titleInfoNode.append_attribute("group_id").set_value(fmt::format("{:08x}", info.group_id).c_str()); |
| 122 | titleInfoNode.append_attribute("app_type").set_value(fmt::format("{:08x}", info.app_type).c_str()); |
| 123 | titleInfoNode.append_child("region").append_child(pugi::node_pcdata).set_value(fmt::format("{}", (uint32)info.region).c_str()); |
| 124 | titleInfoNode.append_child("name").append_child(pugi::node_pcdata).set_value(info.titleName.c_str()); |
| 125 | titleInfoNode.append_child("format").append_child(pugi::node_pcdata).set_value(fmt::format("{}", (uint32)info.titleDataFormat).c_str()); |
| 126 | titleInfoNode.append_child("path").append_child(pugi::node_pcdata).set_value(_pathToUtf8(info.path).c_str()); |
| 127 | if(!info.subPath.empty()) |
| 128 | titleInfoNode.append_child("sub_path").append_child(pugi::node_pcdata).set_value(_pathToUtf8(info.subPath).c_str()); |
| 129 | } |
| 130 | |
| 131 | fs::path tmpPath = fs::path(sTLCacheFilePath.parent_path()).append(fmt::format("{}__tmp", _pathToUtf8(sTLCacheFilePath.filename()))); |
| 132 | std::ofstream fileOut(tmpPath, std::ios::out | std::ios::binary | std::ios::trunc); |
| 133 | if (!fileOut.is_open()) |
| 134 | { |
| 135 | cemuLog_log(LogType::Force, "Unable to store title list in {}", _pathToUtf8(tmpPath)); |
| 136 | return; |
| 137 | } |
| 138 | doc.save(fileOut, " ", 1, pugi::xml_encoding::encoding_utf8); |
| 139 | fileOut.flush(); |
| 140 | fileOut.close(); |
| 141 | |
| 142 | std::error_code ec; |
| 143 | fs::rename(tmpPath, sTLCacheFilePath, ec); |
| 144 | } |
| 145 | |
| 146 | void CafeTitleList::ClearScanPaths() |
| 147 | { |
nothing calls this directly
no test coverage detected