summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-07-04 11:42:40 +0200
committerRémi Verschelde <rverschelde@gmail.com>2019-07-04 11:42:40 +0200
commitc5ea4b27f97df47f6f190204e2b1e4018414a31e (patch)
tree97f3686a9aa42b8b3b9ae033a020ca4d1fb3a50a /editor
parentd6d487d7f70e558972c6750fc0f53a166dbd0fc8 (diff)
FileSystem dock: Improve duplicate check for directory paths
Supersedes and closes #30225.
Diffstat (limited to 'editor')
-rw-r--r--editor/filesystem_dock.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 9301d8c1a4..b74350c98b 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1324,14 +1324,14 @@ void FileSystemDock::_duplicate_operation_confirm() {
return;
}
- String new_path;
String base_dir = to_duplicate.path.get_base_dir();
- if (to_duplicate.is_file) {
- new_path = base_dir.plus_file(new_name);
- } else {
- new_path = base_dir.substr(0, base_dir.find_last("/")).plus_file(new_name);
+ // get_base_dir() returns "some/path" if the original path was "some/path/", so work it around.
+ if (to_duplicate.path.ends_with("/")) {
+ base_dir = base_dir.get_base_dir();
}
+ String new_path = base_dir.plus_file(new_name);
+
//Present a more user friendly warning for name conflict
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->file_exists(new_path) || da->dir_exists(new_path)) {