summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgit apple-llvm automerger <am@git-apple-llvm>2020-12-15 16:46:47 -0800
committergit apple-llvm automerger <am@git-apple-llvm>2020-12-15 18:23:10 -0500
commit207b4ea04a1a7ef24842d9bf477482bd7e663284 (patch)
tree07ba01c028860a84131def85bee91adc28c360c9
parent6af90fed511cd3ade7f20fa58cc5360ecb4c004d (diff)
parent6ec777c2f6496b4fe1d78cc6d6871a3dc931a185 (diff)
downloadllvm-207b4ea04a1a7ef24842d9bf477482bd7e663284.tar.gz
Merge commit '6ec777c2f649' from llvm.org/release/11.x into apple/stable/20200714
-rw-r--r--llvm/lib/Support/Windows/Path.inc14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 365ab01c0a16..a4ffc0ec4313 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -402,6 +402,20 @@ std::error_code is_local(int FD, bool &Result) {
}
static std::error_code setDeleteDisposition(HANDLE Handle, bool Delete) {
+ // First, check if the file is on a network (non-local) drive. If so, don't
+ // set DeleteFile to true, since it prevents opening the file for writes.
+ SmallVector<wchar_t, 128> FinalPath;
+ if (std::error_code EC = realPathFromHandle(Handle, FinalPath))
+ return EC;
+
+ bool IsLocal;
+ if (std::error_code EC = is_local_internal(FinalPath, IsLocal))
+ return EC;
+
+ if (!IsLocal)
+ return std::error_code();
+
+ // The file is on a local drive, set the DeleteFile to true.
FILE_DISPOSITION_INFO Disposition;
Disposition.DeleteFile = Delete;
if (!SetFileInformationByHandle(Handle, FileDispositionInfo, &Disposition,