diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-07-29 14:56:15 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-07-29 14:56:15 +0000 |
commit | ae1727e3ddf100a20f0c760c57fe8866756ea494 (patch) | |
tree | f996c3eb783307b68d371dc8849b39b60adab3ae /llvm/lib/Support/Path.cpp | |
parent | f52eeb11237af5bda4516668d3ee1784fd3b16c5 (diff) | |
download | bcm5719-llvm-ae1727e3ddf100a20f0c760c57fe8866756ea494.tar.gz bcm5719-llvm-ae1727e3ddf100a20f0c760c57fe8866756ea494.zip |
[dsymutil] Simplify temporary file handling.
Dsymutil's update functionality was broken on Windows because we tried
to rename a file while we're holding open handles to that file. TempFile
provides a solution for this through its keep(Twine) method. This patch
changes dsymutil to make use of that functionality.
Differential revision: https://reviews.llvm.org/D49860
llvm-svn: 338216
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index a806da23ec5..098230290ed 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -1157,9 +1157,13 @@ Error TempFile::keep(const Twine &Name) { setDeleteDisposition(H, true); #else std::error_code RenameEC = fs::rename(TmpName, Name); - // If we can't rename, discard the temporary file. - if (RenameEC) - remove(TmpName); + if (RenameEC) { + // If we can't rename, try to copy to work around cross-device link issues. + RenameEC = sys::fs::copy_file(TmpName, Name); + // If we can't rename or copy, discard the temporary file. + if (RenameEC) + remove(TmpName); + } sys::DontRemoveFileOnSignal(TmpName); #endif |