mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-24 05:09:34 +00:00
Fix rename.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123604 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
33d84007b5
commit
283d49c766
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user