[llvm] a27478e - [Support][Windows] Prevent 2s delay when renaming a file that does not exist
Ben Dunbobbin via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 02:41:27 PDT 2020
Author: Ben Dunbobbin
Date: 2020-07-02T10:41:17+01:00
New Revision: a27478e54f5fa99ed17ad6ef149046f9d391f293
URL: https://github.com/llvm/llvm-project/commit/a27478e54f5fa99ed17ad6ef149046f9d391f293
DIFF: https://github.com/llvm/llvm-project/commit/a27478e54f5fa99ed17ad6ef149046f9d391f293.diff
LOG: [Support][Windows] Prevent 2s delay when renaming a file that does not exist
Differential Revision: https://reviews.llvm.org/D82542
Added:
Modified:
llvm/lib/Support/Windows/Path.inc
Removed:
################################################################################
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index ec62e656ddf0..96677e23b660 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -555,6 +555,11 @@ std::error_code rename(const Twine &From, const Twine &To) {
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (FromHandle)
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)
return mapWindowsError(GetLastError());
More information about the llvm-commits
mailing list