diff options
-rw-r--r-- | editor/editor_dir_dialog.cpp | 11 | ||||
-rw-r--r-- | editor/editor_file_dialog.cpp | 8 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 14 |
3 files changed, 19 insertions, 14 deletions
diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 866f28c03b..9fabde93ef 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -156,15 +156,18 @@ void EditorDirDialog::_make_dir_confirm() { String dir = ti->get_metadata(0); - if (EditorFileSystem::get_singleton()->get_filesystem_path(dir + makedirname->get_text())) { + DirAccessRef d = DirAccess::open(dir); + ERR_FAIL_COND_MSG(!d, "Cannot open directory '" + dir + "'."); + + const String stripped_dirname = makedirname->get_text().strip_edges(); + + if (d->dir_exists(stripped_dirname)) { mkdirerr->set_text(TTR("Could not create folder. File with that name already exists.")); mkdirerr->popup_centered(); return; } - DirAccessRef d = DirAccess::open(dir); - ERR_FAIL_COND_MSG(!d, "Cannot open directory '" + dir + "'."); - Error err = d->make_dir(makedirname->get_text()); + Error err = d->make_dir(stripped_dirname); if (err != OK) { mkdirerr->popup_centered(Size2(250, 80) * EDSCALE); } else { diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 179894915b..d5105b5ac8 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1099,16 +1099,18 @@ EditorFileDialog::Access EditorFileDialog::get_access() const { } void EditorFileDialog::_make_dir_confirm() { - if (EditorFileSystem::get_singleton()->get_filesystem_path(makedirname->get_text().strip_edges())) { + const String stripped_dirname = makedirname->get_text().strip_edges(); + + if (dir_access->dir_exists(stripped_dirname)) { error_dialog->set_text(TTR("Could not create folder. File with that name already exists.")); error_dialog->popup_centered(Size2(250, 50) * EDSCALE); makedirname->set_text(""); // Reset label. return; } - Error err = dir_access->make_dir(makedirname->get_text().strip_edges()); + Error err = dir_access->make_dir(stripped_dirname); if (err == OK) { - dir_access->change_dir(makedirname->get_text().strip_edges()); + dir_access->change_dir(stripped_dirname); invalidate(); update_filters(); update_dir(); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index ee7ed77957..f6d00470d1 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1427,18 +1427,18 @@ void FileSystemDock::_make_dir_confirm() { directory = directory.get_base_dir(); } - if (EditorFileSystem::get_singleton()->get_filesystem_path(directory + dir_name)) { - EditorNode::get_singleton()->show_warning(TTR("Could not create folder. File with that name already exists.")); - return; - } - print_verbose("Making folder " + dir_name + " in " + directory); DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); Error err = da->change_dir(directory); - if (err == OK) { - err = da->make_dir(dir_name); + ERR_FAIL_COND_MSG(err != OK, "Cannot open directory '" + directory + "'."); + + if (da->dir_exists(directory)) { + EditorNode::get_singleton()->show_warning(TTR("Could not create folder. File with that name already exists.")); + return; } + err = da->make_dir(dir_name); + if (err == OK) { print_verbose("FileSystem: calling rescan."); _rescan(); |