MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / loadHashDatabase

Method loadHashDatabase

pcsx2/GameDatabase.cpp:1175–1224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1173}
1174
1175bool GameDatabase::loadHashDatabase()
1176{
1177 if (!s_hash_database.empty())
1178 return true;
1179
1180 Common::Timer load_timer;
1181
1182 const std::string path(Path::Combine(EmuFolders::Resources, HASHDB_YAML_FILE_NAME));
1183 const std::string name(HASHDB_YAML_FILE_NAME);
1184
1185 std::optional<std::string> buffer = FileSystem::ReadFileToString(path.c_str());
1186 if (!buffer.has_value())
1187 {
1188 Console.Error("[HashDatabase] Unable to open hash database file, file does not exist.");
1189 return false;
1190 }
1191
1192 ryml::csubstr yaml = ryml::to_csubstr(*buffer);
1193
1194 Error error;
1195 std::optional<ryml::Tree> tree = ParseYAMLFromString(yaml, ryml::to_csubstr(name), &error);
1196 if (!tree.has_value())
1197 {
1198 Console.ErrorFmt("[HashDatabase] Failed to parse hash database file {}:", path);
1199 Console.Error(error.GetDescription());
1200 return false;
1201 }
1202
1203 ryml::NodeRef root = tree->rootref();
1204
1205 bool okay = true;
1206 for (const ryml::NodeRef& n : root.children())
1207 {
1208 if (!parseHashDatabaseEntry(n))
1209 {
1210 okay = false;
1211 break;
1212 }
1213 }
1214
1215 if (!okay)
1216 {
1217 s_track_hash_to_entry_map.clear();
1218 s_hash_database.clear();
1219 return false;
1220 }
1221
1222 Console.WriteLn(Color_StrongGreen, "[HashDatabase] Loaded YAML in %.0f ms", load_timer.GetTimeMilliseconds());
1223 return true;
1224}
1225
1226void GameDatabase::unloadHashDatabase()
1227{

Callers

nothing calls this directly

Calls 11

CombineFunction · 0.85
ParseYAMLFromStringFunction · 0.85
parseHashDatabaseEntryFunction · 0.85
GetDescriptionMethod · 0.80
GetTimeMillisecondsMethod · 0.80
emptyMethod · 0.45
c_strMethod · 0.45
ErrorMethod · 0.45
ErrorFmtMethod · 0.45
clearMethod · 0.45
WriteLnMethod · 0.45

Tested by

no test coverage detected