mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-29 13:32:33 +00:00
Don't fallback to copy + delete in rename.
Rename's documentation says "Files are renamed as if by POSIX rename()". and it is used for atomically updating output files from a temporary. Having rename fallback to a non atomic copy has the potential to hide bugs, like using a temporary file in /tmp instead of a unique name next to the final destination. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186483 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8de25f031d
commit
f33cab4898
@ -456,17 +456,8 @@ error_code rename(const Twine &from, const Twine &to) {
|
|||||||
StringRef f = from.toNullTerminatedStringRef(from_storage);
|
StringRef f = from.toNullTerminatedStringRef(from_storage);
|
||||||
StringRef t = to.toNullTerminatedStringRef(to_storage);
|
StringRef t = to.toNullTerminatedStringRef(to_storage);
|
||||||
|
|
||||||
if (::rename(f.begin(), t.begin()) == -1) {
|
if (::rename(f.begin(), t.begin()) == -1)
|
||||||
// If it's a cross device link, copy then delete, otherwise return the error
|
return error_code(errno, system_category());
|
||||||
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 error_code::success();
|
return error_code::success();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user