diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-01-16 22:18:41 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-01-16 22:18:41 +0000 |
commit | ec202ee69a3c3e368e0bae249a6a621c53081ed7 (patch) | |
tree | ff49cc774dce2c76c42be3dd5d9fa5c44d3995ed /llvm/lib/Support/Unix/PathV2.inc | |
parent | 128ddbf4129704e0b08026f4f3a6054f869ad406 (diff) | |
download | bcm5719-llvm-ec202ee69a3c3e368e0bae249a6a621c53081ed7.tar.gz bcm5719-llvm-ec202ee69a3c3e368e0bae249a6a621c53081ed7.zip |
Fix rename.
llvm-svn: 123604
Diffstat (limited to 'llvm/lib/Support/Unix/PathV2.inc')
-rw-r--r-- | llvm/lib/Support/Unix/PathV2.inc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Support/Unix/PathV2.inc b/llvm/lib/Support/Unix/PathV2.inc index 056708a7b0b..03ff28367e4 100644 --- a/llvm/lib/Support/Unix/PathV2.inc +++ b/llvm/lib/Support/Unix/PathV2.inc @@ -230,8 +230,17 @@ error_code rename(const Twine &from, const Twine &to) { StringRef f = from.toNullTerminatedStringRef(from_storage); StringRef t = to.toNullTerminatedStringRef(to_storage); - if (::rename(f.begin(), t.begin()) == -1) - return error_code(errno, system_category()); + if (::rename(f.begin(), t.begin()) == -1) { + // If it's a cross device link, copy then delete, otherwise return the error + if (errno == EXDEV) { + if (error_code ec = copy_file(from, to, copy_option::overwrite_if_exists)) + return ec; + bool Existed; + if (error_code ec = remove(from, Existed)) + return ec; + } else + return error_code(errno, system_category()); + } return success; } |