Host: Add GetResourceFileTimestamp()

This commit is contained in:
Connor McLaughlin 2022-08-10 21:31:06 +10:00 committed by refractionpcsx2
parent 9f9f8e0e39
commit a228582984
3 changed files with 24 additions and 0 deletions

View File

@ -1362,6 +1362,16 @@ std::optional<std::string> Host::ReadResourceFileToString(const char* filename)
return ret; return ret;
} }
std::optional<std::time_t> Host::GetResourceFileTimestamp(const char* filename)
{
const std::string path(Path::Combine(EmuFolders::Resources, filename));
FILESYSTEM_STAT_DATA sd;
if (!FileSystem::StatFile(filename, &sd))
return std::nullopt;
return sd.ModificationTime;
}
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message)
{ {
if (!title.empty() && !message.empty()) if (!title.empty() && !message.empty())

View File

@ -17,6 +17,7 @@
#include "common/Pcsx2Defs.h" #include "common/Pcsx2Defs.h"
#include <ctime>
#include <functional> #include <functional>
#include <string> #include <string>
#include <string_view> #include <string_view>
@ -52,6 +53,9 @@ namespace Host
/// Reads a resource file file from the resources directory as a string. /// Reads a resource file file from the resources directory as a string.
std::optional<std::string> ReadResourceFileToString(const char* filename); std::optional<std::string> ReadResourceFileToString(const char* filename);
/// Returns the modified time of a resource.
std::optional<std::time_t> GetResourceFileTimestamp(const char* filename);
/// Adds OSD messages, duration is in seconds. /// Adds OSD messages, duration is in seconds.
void AddOSDMessage(std::string message, float duration = 2.0f); void AddOSDMessage(std::string message, float duration = 2.0f);
void AddKeyedOSDMessage(std::string key, std::string message, float duration = 2.0f); void AddKeyedOSDMessage(std::string key, std::string message, float duration = 2.0f);

View File

@ -84,6 +84,16 @@ std::optional<std::string> Host::ReadResourceFileToString(const char* filename)
return ret; return ret;
} }
std::optional<std::time_t> Host::GetResourceFileTimestamp(const char* filename)
{
const std::string path(Path::Combine(EmuFolders::Resources, filename));
FILESYSTEM_STAT_DATA sd;
if (!FileSystem::StatFile(filename, &sd))
return std::nullopt;
return sd.ModificationTime;
}
bool Host::GetBoolSettingValue(const char* section, const char* key, bool default_value /* = false */) bool Host::GetBoolSettingValue(const char* section, const char* key, bool default_value /* = false */)
{ {
return default_value; return default_value;