mirror of https://github.com/PCSX2/pcsx2.git
GameDatabase: Use resource abstraction to read yaml
This commit is contained in:
parent
2c32c374fb
commit
1859ede325
|
@ -254,24 +254,14 @@ static void initDatabase()
|
|||
});
|
||||
try
|
||||
{
|
||||
auto filePath = Host::getResourceFilePath(GAMEDB_YAML_FILE_NAME);
|
||||
if (!filePath.has_value())
|
||||
std::optional<std::vector<u8>> buf(Host::ReadResourceFile(GAMEDB_YAML_FILE_NAME));
|
||||
if (!buf.has_value())
|
||||
{
|
||||
Console.Error("[GameDB] Unable to open GameDB file, file does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto dbStream = getFileStream(filePath.value());
|
||||
|
||||
dbStream.seekg(0, std::ios::end);
|
||||
const size_t size = dbStream.tellg();
|
||||
dbStream.seekg(0, std::ios::beg);
|
||||
|
||||
std::vector<char> buf(size);
|
||||
dbStream.read(buf.data(), size);
|
||||
dbStream.close();
|
||||
|
||||
const ryml::substr view = c4::basic_substring<char>(buf.data(), size);
|
||||
const ryml::substr view = c4::basic_substring<char>(reinterpret_cast<char*>(buf->data()), buf->size());
|
||||
ryml::Tree tree = ryml::parse(view);
|
||||
ryml::NodeRef root = tree.rootref();
|
||||
|
||||
|
|
|
@ -41,7 +41,4 @@ namespace Host
|
|||
|
||||
/// Reads a resource file file from the resources directory as a string.
|
||||
std::optional<std::string> ReadResourceFileToString(const char* filename);
|
||||
|
||||
/// Returns the full filepath to a resource file, if it exists.
|
||||
std::optional<std::string> getResourceFilePath(const char* filename);
|
||||
} // namespace Host
|
||||
|
|
|
@ -67,13 +67,3 @@ std::optional<std::string> Host::ReadResourceFileToString(const char* filename)
|
|||
return ret;
|
||||
}
|
||||
|
||||
std::optional<std::string> Host::getResourceFilePath(const char* filename)
|
||||
{
|
||||
const std::string full_filename(Path::CombineStdString(EmuFolders::Resources, filename));
|
||||
if (!FileSystem::FileExists(full_filename.c_str()))
|
||||
{
|
||||
Console.Error("Resource file does not exist '%s'", filename);
|
||||
return std::nullopt;
|
||||
}
|
||||
return full_filename;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue