Merge pull request #59495 from DanielKriz/feature/better-dir-alert-msgs

This commit is contained in:
Rémi Verschelde 2022-03-25 16:22:37 +01:00 committed by GitHub
commit c14df99124
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -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 {

View File

@ -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());

View File

@ -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);