File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -402,6 +402,20 @@ std::error_code is_local(int FD, bool &Result) {
402
402
}
403
403
404
404
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.
405
419
FILE_DISPOSITION_INFO Disposition;
406
420
Disposition.DeleteFile = Delete;
407
421
if (!SetFileInformationByHandle (Handle, FileDispositionInfo, &Disposition,
You can’t perform that action at this time.
0 commit comments