[PATCH] D81803: [Support] PR42623: Avoid setting the delete-on-close bit if a TempFile doesn't reside on a local drive
Ronald Wampler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 30 10:44:21 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79657e2339b5: [Support] PR42623: Avoid setting the delete-on-close bit if a TempFile doesn't… (authored by rdwampler).
Changed prior to commit:
https://reviews.llvm.org/D81803?vs=295298&id=301955#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81803/new/
https://reviews.llvm.org/D81803
Files:
llvm/lib/Support/Windows/Path.inc
Index: llvm/lib/Support/Windows/Path.inc
===================================================================
--- llvm/lib/Support/Windows/Path.inc
+++ llvm/lib/Support/Windows/Path.inc
@@ -402,6 +402,20 @@
}
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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81803.301955.patch
Type: text/x-patch
Size: 935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201030/e5674050/attachment.bin>
More information about the llvm-commits
mailing list