summaryrefslogtreecommitdiff
path: root/core/bind/core_bind.cpp
diff options
context:
space:
mode:
authorTomasz Chabora <kobewi4e@gmail.com>2020-10-07 16:30:11 +0200
committerTomasz Chabora <kobewi4e@gmail.com>2020-10-08 13:00:23 +0200
commitbb2684f4a71ea6cc150824223a3ec864770a56e2 (patch)
treea2037e11f272dfe7d441444c359f981608e0dca0 /core/bind/core_bind.cpp
parent8be6db951d8f46197160a9e86868a729f74fc36f (diff)
Cancel rename if file does not exist
Diffstat (limited to 'core/bind/core_bind.cpp')
-rw-r--r--core/bind/core_bind.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index c68222c767..88e31c56fe 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -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.");
if (!p_from.is_rel_path()) {
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);
memdelete(d);
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);
}