mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 11:32:13 +00:00
[Linux/BSD] Fix cross-device rename.
This commit is contained in:
parent
f4af8201ba
commit
4cc9d2f437
@ -410,7 +410,17 @@ Error DirAccessUnix::rename(String p_path, String p_new_path) {
|
||||
p_new_path = p_new_path.left(-1);
|
||||
}
|
||||
|
||||
return ::rename(p_path.utf8().get_data(), p_new_path.utf8().get_data()) == 0 ? OK : FAILED;
|
||||
int res = ::rename(p_path.utf8().get_data(), p_new_path.utf8().get_data());
|
||||
if (res != 0 && errno == EXDEV) { // Cross-device move, use copy and remove.
|
||||
Error err = OK;
|
||||
err = copy(p_path, p_new_path);
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
return remove(p_path);
|
||||
} else {
|
||||
return (res == 0) ? OK : FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
Error DirAccessUnix::remove(String p_path) {
|
||||
|
Loading…
Reference in New Issue
Block a user