Skip to content

Commit

Permalink
fs-api: extend host API to allow retrieval of a resource file path
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser authored and refractionpcsx2 committed Dec 25, 2021
1 parent e313ead commit 4719e52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pcsx2/Host.h
Expand Up @@ -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
11 changes: 11 additions & 0 deletions pcsx2/gui/AppHost.cpp
Expand Up @@ -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;
}

0 comments on commit 4719e52

Please sign in to comment.