Merge pull request #42621 from KoBeWi/into_nothingness_no_more
Cancel rename if file does not exist
This commit is contained in:
commit
abbd58dcb0
1 changed files with 2 additions and 0 deletions
|
@ -1743,11 +1743,13 @@ Error _Directory::rename(String p_from, String p_to) {
|
||||||
ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
|
ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
|
||||||
if (!p_from.is_rel_path()) {
|
if (!p_from.is_rel_path()) {
|
||||||
DirAccess *d = DirAccess::create_for_path(p_from);
|
DirAccess *d = DirAccess::create_for_path(p_from);
|
||||||
|
ERR_FAIL_COND_V_MSG(!d->file_exists(p_from), ERR_DOES_NOT_EXIST, "File does not exist.");
|
||||||
Error err = d->rename(p_from, p_to);
|
Error err = d->rename(p_from, p_to);
|
||||||
memdelete(d);
|
memdelete(d);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ERR_FAIL_COND_V_MSG(!d->file_exists(p_from), ERR_DOES_NOT_EXIST, "File does not exist.");
|
||||||
return d->rename(p_from, p_to);
|
return d->rename(p_from, p_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue