Skip to content

Commit 207b4ea

Browse files
author
git apple-llvm automerger
committed
Merge commit '6ec777c2f649' from llvm.org/release/11.x into apple/stable/20200714
2 parents 6af90fe + 6ec777c commit 207b4ea

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/lib/Support/Windows/Path.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,20 @@ std::error_code is_local(int FD, bool &Result) {
402402
}
403403

404404
static std::error_code setDeleteDisposition(HANDLE Handle, bool Delete) {
405+
// First, check if the file is on a network (non-local) drive. If so, don't
406+
// set DeleteFile to true, since it prevents opening the file for writes.
407+
SmallVector<wchar_t, 128> FinalPath;
408+
if (std::error_code EC = realPathFromHandle(Handle, FinalPath))
409+
return EC;
410+
411+
bool IsLocal;
412+
if (std::error_code EC = is_local_internal(FinalPath, IsLocal))
413+
return EC;
414+
415+
if (!IsLocal)
416+
return std::error_code();
417+
418+
// The file is on a local drive, set the DeleteFile to true.
405419
FILE_DISPOSITION_INFO Disposition;
406420
Disposition.DeleteFile = Delete;
407421
if (!SetFileInformationByHandle(Handle, FileDispositionInfo, &Disposition,

0 commit comments

Comments
 (0)