diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2023-06-08 22:20:52 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2023-06-08 22:20:52 -0500 |
| commit | afa498fa2ff1b88b851cfa53d96ba04d241f2ffe (patch) | |
| tree | fabb56d986a39dc10c22a986c22dd0cbea3dadc0 /Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp | |
| parent | 429b2eca8a90f895516203d35b5f9b69f1217151 (diff) | |
VideoCommon: update DirectFilesystemAssetLibrary to not throw exceptions when a file no longer exists
Diffstat (limited to 'Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp index bbb3a644f5..9c126bf9e1 100644 --- a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp +++ b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp @@ -4,6 +4,7 @@ #include "VideoCommon/Assets/DirectFilesystemAssetLibrary.h" #include <algorithm> +#include <fmt/os.h> #include "Common/FileUtil.h" #include "Common/Logging/Log.h" @@ -35,7 +36,10 @@ DirectFilesystemAssetLibrary::GetLastAssetWriteTime(const AssetID& asset_id) con CustomAssetLibrary::TimeType max_entry; for (const auto& [key, value] : asset_map_path) { - const auto tp = std::filesystem::last_write_time(value); + std::error_code ec; + const auto tp = std::filesystem::last_write_time(value, ec); + if (ec) + continue; if (tp > max_entry) max_entry = tp; } @@ -59,7 +63,14 @@ CustomAssetLibrary::LoadInfo DirectFilesystemAssetLibrary::LoadTexture(const Ass } const auto& asset_path = asset_map.begin()->second; - const auto last_loaded_time = std::filesystem::last_write_time(asset_path); + std::error_code ec; + const auto last_loaded_time = std::filesystem::last_write_time(asset_path, ec); + if (ec) + { + ERROR_LOG_FMT(VIDEO, "Asset '{}' error - failed to get last write time with error '{}'!", + asset_id, ec); + return {}; + } auto ext = asset_path.extension().string(); Common::ToLower(&ext); if (ext == ".dds") |
