Fix 4eaeccd: FioRemove should return false if the file does not exist. (#14619)

This commit is contained in:
Kuhnovic
2025-09-15 21:17:18 +02:00
committed by dP
parent ad172d7a66
commit 5dbcbb1be4

View File

@@ -328,9 +328,12 @@ bool FioRemove(const std::string &filename)
{ {
std::filesystem::path path = OTTD2FS(filename); std::filesystem::path path = OTTD2FS(filename);
std::error_code error_code; std::error_code error_code;
std::filesystem::remove(path, error_code); if (!std::filesystem::remove(path, error_code)) {
if (error_code) { if (error_code) {
Debug(misc, 0, "Removing {} failed: {}", filename, error_code.message()); Debug(misc, 0, "Removing {} failed: {}", filename, error_code.message());
} else {
Debug(misc, 0, "Removing {} failed: file does not exist", filename);
}
return false; return false;
} }
return true; return true;