[PATCH] D50048: [Windows FS] Allow moving files in TempFile::keep
Jeremy Morse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 3 03:14:11 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338841: [Windows FS] Allow moving files in TempFile::keep (authored by jmorse, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D50048?vs=158492&id=158962#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50048
Files:
llvm/trunk/lib/Support/Path.cpp
llvm/trunk/lib/Support/Windows/Path.inc
Index: llvm/trunk/lib/Support/Windows/Path.inc
===================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc
+++ llvm/trunk/lib/Support/Windows/Path.inc
@@ -450,7 +450,7 @@
if (std::error_code EC2 = realPathFromHandle(FromHandle, WideFrom))
return EC2;
if (::MoveFileExW(WideFrom.begin(), WideTo.begin(),
- MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
+ MOVEFILE_REPLACE_EXISTING))
return std::error_code();
return mapWindowsError(GetLastError());
}
Index: llvm/trunk/lib/Support/Path.cpp
===================================================================
--- llvm/trunk/lib/Support/Path.cpp
+++ llvm/trunk/lib/Support/Path.cpp
@@ -1159,8 +1159,16 @@
// If we can't cancel the delete don't rename.
auto H = reinterpret_cast<HANDLE>(_get_osfhandle(FD));
std::error_code RenameEC = setDeleteDisposition(H, false);
- if (!RenameEC)
+ if (!RenameEC) {
RenameEC = rename_fd(FD, Name);
+ // If rename failed because it's cross-device, copy instead
+ if (RenameEC ==
+ std::error_code(ERROR_NOT_SAME_DEVICE, std::system_category())) {
+ RenameEC = copy_file(TmpName, Name);
+ setDeleteDisposition(H, true);
+ }
+ }
+
// If we can't rename, discard the temporary file.
if (RenameEC)
setDeleteDisposition(H, true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50048.158962.patch
Type: text/x-patch
Size: 1406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180803/92a6bc46/attachment.bin>
More information about the llvm-commits
mailing list