summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2023-08-13 16:46:37 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2023-08-15 22:02:28 -0500
commiteeb73460ab5991707b8d1561b241b913f41c1db9 (patch)
tree6dd5843ae6cf2b3246fc2bdca60b6ea477ced724 /Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
parent2537f4db9137a5db8d5dfbf180fa864ae0f2a351 (diff)
VideoCommon: asset load time is now stored as a chrono system_clock time, so that times can be fabricated in a future feature (without creating a file to do so)
Diffstat (limited to 'Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp')
-rw-r--r--Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
index cc21549e54..abf09ef1ce 100644
--- a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
+++ b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
@@ -17,6 +17,20 @@ namespace VideoCommon
{
namespace
{
+std::chrono::system_clock::time_point FileTimeToSysTime(std::filesystem::file_time_type file_time)
+{
+#ifdef _WIN32
+ return std::chrono::clock_cast<std::chrono::system_clock>(file_time);
+#else
+ // Note: all compilers should switch to chrono::clock_cast
+ // once it is available for use
+ const auto system_time_now = std::chrono::system_clock::now();
+ const auto file_time_now = decltype(file_time)::clock::now();
+ return std::chrono::time_point_cast<std::chrono::system_clock::duration>(
+ file_time - file_time_now + system_time_now);
+#endif
+}
+
std::size_t GetAssetSize(const CustomTextureData& data)
{
std::size_t total = 0;
@@ -42,8 +56,9 @@ DirectFilesystemAssetLibrary::GetLastAssetWriteTime(const AssetID& asset_id) con
const auto tp = std::filesystem::last_write_time(value, ec);
if (ec)
continue;
- if (tp > max_entry)
- max_entry = tp;
+ auto tp_sys = FileTimeToSysTime(tp);
+ if (tp_sys > max_entry)
+ max_entry = tp_sys;
}
return max_entry;
}
@@ -235,7 +250,7 @@ CustomAssetLibrary::LoadInfo DirectFilesystemAssetLibrary::LoadTexture(const Ass
if (!LoadMips(asset_path, data))
return {};
- return LoadInfo{GetAssetSize(*data), last_loaded_time};
+ return LoadInfo{GetAssetSize(*data), FileTimeToSysTime(last_loaded_time)};
}
else if (ext == ".png")
{
@@ -252,7 +267,7 @@ CustomAssetLibrary::LoadInfo DirectFilesystemAssetLibrary::LoadTexture(const Ass
if (!LoadMips(asset_path, data))
return {};
- return LoadInfo{GetAssetSize(*data), last_loaded_time};
+ return LoadInfo{GetAssetSize(*data), FileTimeToSysTime(last_loaded_time)};
}
ERROR_LOG_FMT(VIDEO, "Asset '{}' error - extension '{}' unknown!", asset_id, ext);