diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-08-29 17:50:33 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-08-29 17:50:33 +0000 |
commit | 8568f9cb5af587ccee4088af3e2d617b3c30d403 (patch) | |
tree | 38ef3950af2e183a6c1c23947e35e837fce15a9a /lib/Support/Path.cpp | |
parent | d0a9cbdae159210824ddf2da138e2dcaecbe1cd4 (diff) |
Notes
Diffstat (limited to 'lib/Support/Path.cpp')
-rw-r--r-- | lib/Support/Path.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 098230290ed28..768a819c8d05b 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -1150,8 +1150,16 @@ Error TempFile::keep(const Twine &Name) { // 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); |