mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 05:40:01 -06:00
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)
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user