[Support][Windows] Prevent 2s delay when renaming a file that does not exist

Differential Revision: https://reviews.llvm.org/D82542
This commit is contained in:
Ben Dunbobbin 2020-07-01 17:49:30 +01:00
parent 7f903873b8
commit a27478e54f
1 changed files with 5 additions and 0 deletions

View File

@ -555,6 +555,11 @@ std::error_code rename(const Twine &From, const Twine &To) {
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (FromHandle) if (FromHandle)
break; break;
// We don't want to loop if the file doesn't exist.
auto EC = mapWindowsError(GetLastError());
if (EC == errc::no_such_file_or_directory)
return EC;
} }
if (!FromHandle) if (!FromHandle)
return mapWindowsError(GetLastError()); return mapWindowsError(GetLastError());