[VFS] Fixed allow_game_relative_writes to write invalid cached entries

This PR fixes https://github.com/xenia-canary/xenia-canary/issues/123 a bug where files would not write to the host if they were deleted from the host filesystem during runtime.
This commit is contained in:
Adrian
2023-02-04 17:18:24 +00:00
committed by Radosław Gliński
parent 333d7c2767
commit 321dd75e05
3 changed files with 21 additions and 3 deletions

View File

@@ -103,9 +103,10 @@ bool HostPathEntry::DeleteEntryInternal(Entry* entry) {
auto removed = std::filesystem::remove_all(full_path, ec);
return removed >= 1 && removed != static_cast<std::uintmax_t>(-1);
} else {
// Delete file.
// Delete file only if it exists.
return !std::filesystem::is_directory(full_path) &&
std::filesystem::remove(full_path, ec);
(!std::filesystem::exists(full_path) ||
std::filesystem::remove(full_path, ec));
}
}