From 3fdbdd838074b3f6b78e6f6c2fae1f3a407c2446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20L=C3=BCders?= Date: Tue, 5 Mar 2019 08:52:45 +0100 Subject: [PATCH] Fixes misleading error message when trying to export This patch fixes the misleading error message when users try to "export all" into an invalid destination path. Closes #26539 --- editor/editor_export.cpp | 4 ++++ editor/project_export.cpp | 6 +++++- platform/android/export/export.cpp | 4 ++++ platform/iphone/export/export.cpp | 4 ++++ platform/javascript/export/export.cpp | 4 ++++ platform/osx/export/export.cpp | 4 ++++ platform/uwp/export/export.cpp | 4 ++++ 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 75708431ecd..249bbb2a392 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1456,6 +1456,10 @@ List EditorExportPlatformPC::get_binary_extensions(const Ref &p_preset, bool p_debug, const String &p_path, int p_flags) { ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); + if (!FileAccess::exists(p_path.get_base_dir())) { + return ERR_FILE_BAD_PATH; + } + String custom_debug = p_preset->get("custom_template/debug"); String custom_release = p_preset->get("custom_template/release"); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 831ebde3a6c..82a6a07805d 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -1012,7 +1012,11 @@ void ProjectExportDialog::_export_all(bool p_debug) { Error err = platform->export_project(preset, p_debug, preset->get_export_path(), 0); if (err != OK) { - error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " " + platform->get_name()); + if (err == ERR_FILE_BAD_PATH) { + error_dialog->set_text(TTR("The given export path doesn't exist:") + "\n" + preset->get_export_path().get_base_dir()); + } else { + error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " " + platform->get_name()); + } error_dialog->show(); error_dialog->popup_centered_minsize(Size2(300, 80)); ERR_PRINT("Failed to export project"); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 8ffd3552195..0f2455914d9 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1489,6 +1489,10 @@ public: } } + if (!FileAccess::exists(p_path.get_base_dir())) { + return ERR_FILE_BAD_PATH; + } + FileAccess *src_f = NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index c45931fdfd7..7b3f99da9ab 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -840,6 +840,10 @@ Error EditorExportPlatformIOS::export_project(const Ref &p_p } } + if (!FileAccess::exists(dest_dir)) { + return ERR_FILE_BAD_PATH; + } + DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (da) { String current_dir = da->get_current_dir(); diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 57044336505..d9f08f2a1bf 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -211,6 +211,10 @@ Error EditorExportPlatformJavaScript::export_project(const Refshow_warning(TTR("Template file not found:") + "\n" + template_path); return ERR_FILE_NOT_FOUND; diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index b8f6977b39d..a0eccceed01 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -425,6 +425,10 @@ Error EditorExportPlatformOSX::export_project(const Ref &p_p } } + if (!FileAccess::exists(p_path.get_base_dir())) { + return ERR_FILE_BAD_PATH; + } + FileAccess *src_f = NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index a4655117a76..8405608dd65 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -1265,6 +1265,10 @@ public: } } + if (!FileAccess::exists(p_path.get_base_dir())) { + return ERR_FILE_BAD_PATH; + } + Error err = OK; FileAccess *fa_pack = FileAccess::open(p_path, FileAccess::WRITE, &err);