From 4719e52c6e3996c8f913b484b0c79f67c97d782e Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Thu, 23 Dec 2021 22:00:22 -0500 Subject: [PATCH] fs-api: extend host API to allow retrieval of a resource file path --- pcsx2/Host.h | 3 +++ pcsx2/gui/AppHost.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+) 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; +}