fs-api: extend host API to allow retrieval of a resource file path

This commit is contained in:
Tyler Wilding 2021-12-23 22:00:22 -05:00 committed by refractionpcsx2
parent e313eadcd2
commit 4719e52c6e
2 changed files with 14 additions and 0 deletions

View File

@ -41,4 +41,7 @@ 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

View File

@ -66,3 +66,14 @@ 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;
}