diff --git a/pcsx2/Host.h b/pcsx2/Host.h index b980ac2980..7a0b2d1820 100644 --- a/pcsx2/Host.h +++ b/pcsx2/Host.h @@ -41,4 +41,7 @@ namespace Host /// Reads a resource file file from the resources directory as a string. std::optional ReadResourceFileToString(const char* filename); + + /// Returns the full filepath to a resource file, if it exists. + std::optional getResourceFilePath(const char* filename); } // namespace Host diff --git a/pcsx2/gui/AppHost.cpp b/pcsx2/gui/AppHost.cpp index fb6e65eca7..efb82302c6 100644 --- a/pcsx2/gui/AppHost.cpp +++ b/pcsx2/gui/AppHost.cpp @@ -66,3 +66,14 @@ std::optional Host::ReadResourceFileToString(const char* filename) return ret; } + +std::optional 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; +}