summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-03-25 16:22:37 +0100
committerGitHub <noreply@github.com>2022-03-25 16:22:37 +0100
commitc14df99124aaae00de47f58b8930ce81a5738653 (patch)
treefac4bcad475a06bbcdac310a27a5d40c883cda0d /editor
parentfbfa12dd762bbf65bf26b574a13e5fffa57879a6 (diff)
parent2a6cb29a0f171136f16ad6b2f487744f1c6c89e2 (diff)
Merge pull request #59495 from DanielKriz/feature/better-dir-alert-msgs
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_dir_dialog.cpp7
-rw-r--r--editor/editor_file_dialog.cpp7
-rw-r--r--editor/filesystem_dock.cpp6
3 files changed, 19 insertions, 1 deletions
diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp
index 32ef87a4ab..866f28c03b 100644
--- a/editor/editor_dir_dialog.cpp
+++ b/editor/editor_dir_dialog.cpp
@@ -156,10 +156,15 @@ void EditorDirDialog::_make_dir_confirm() {
String dir = ti->get_metadata(0);
+ if (EditorFileSystem::get_singleton()->get_filesystem_path(dir + makedirname->get_text())) {
+ 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());
-
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 31f2f24066..0c2faacf02 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -1092,6 +1092,13 @@ EditorFileDialog::Access EditorFileDialog::get_access() const {
}
void EditorFileDialog::_make_dir_confirm() {
+ if (EditorFileSystem::get_singleton()->get_filesystem_path(makedirname->get_text().strip_edges())) {
+ 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());
if (err == OK) {
dir_access->change_dir(makedirname->get_text().strip_edges());
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 038cc2ab2f..2100a787c8 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1413,6 +1413,12 @@ void FileSystemDock::_make_dir_confirm() {
if (!directory.ends_with("/")) {
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);