MCPcopy Create free account
hub / github.com/cemu-project/Cemu / StoreCacheFile

Method StoreCacheFile

src/Cafe/TitleList/TitleList.cpp:101–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void 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
146void CafeTitleList::ClearScanPaths()
147{

Callers

nothing calls this directly

Calls 9

cemu_assert_debugFunction · 0.85
formatFunction · 0.85
_pathToUtf8Function · 0.85
MakeCacheEntryMethod · 0.80
cemuLog_logFunction · 0.50
emptyMethod · 0.45
c_strMethod · 0.45
appendMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected