diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-08-18 00:14:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-18 00:14:29 +0200 |
| commit | a08792033a9634f628a75163cd60427c92987c2d (patch) | |
| tree | b4d04191d41a9b65100628e179393d24cb8e796a /Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp | |
| parent | 23ae8c439c3826973a00a29b6d221d3836bc7415 (diff) | |
| parent | eeb73460ab5991707b8d1561b241b913f41c1db9 (diff) | |
Merge pull request #12103 from iwubcode/asset_load_system_time
VideoCommon: asset load time is now stored as a chrono system_clock time
Diffstat (limited to 'Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp index 3d92c7fb82..7a1f84ca08 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); |
