| 87 | } |
| 88 | |
| 89 | void ProjectDialog::_validate_path() { |
| 90 | _set_message("", MESSAGE_SUCCESS, PROJECT_PATH); |
| 91 | _set_message("", MESSAGE_SUCCESS, INSTALL_PATH); |
| 92 | |
| 93 | if (project_name->get_text().strip_edges().is_empty()) { |
| 94 | _set_message(TTRC("It would be a good idea to name your project."), MESSAGE_ERROR); |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); |
| 99 | String path = project_path->get_text().simplify_path(); |
| 100 | |
| 101 | String target_path = path; |
| 102 | InputType target_path_input_type = PROJECT_PATH; |
| 103 | |
| 104 | if (mode == MODE_IMPORT) { |
| 105 | if (path.get_file().strip_edges() == "project.godot") { |
| 106 | path = path.get_base_dir(); |
| 107 | project_path->set_text(path); |
| 108 | } |
| 109 | |
| 110 | if (is_zip_file(d, path)) { |
| 111 | zip_path = path; |
| 112 | } else if (is_zip_file(d, path.strip_edges())) { |
| 113 | zip_path = path.strip_edges(); |
| 114 | } else { |
| 115 | zip_path = ""; |
| 116 | } |
| 117 | |
| 118 | if (!zip_path.is_empty()) { |
| 119 | target_path = install_path->get_text().simplify_path(); |
| 120 | target_path_input_type = INSTALL_PATH; |
| 121 | |
| 122 | create_dir->show(); |
| 123 | install_path_container->show(); |
| 124 | |
| 125 | Ref<FileAccess> io_fa; |
| 126 | zlib_filefunc_def io = zipio_create_io(&io_fa); |
| 127 | |
| 128 | unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io); |
| 129 | if (!pkg) { |
| 130 | _set_message(TTRC("Invalid \".zip\" project file; it is not in ZIP format."), MESSAGE_ERROR); |
| 131 | unzClose(pkg); |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | int ret = unzGoToFirstFile(pkg); |
| 136 | while (ret == UNZ_OK) { |
| 137 | unz_file_info info; |
| 138 | char fname[16384]; |
| 139 | ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); |
| 140 | ERR_FAIL_COND_MSG(ret != UNZ_OK, "Failed to get current file info."); |
| 141 | |
| 142 | String name = String::utf8(fname); |
| 143 | |
| 144 | // Skip the __MACOSX directory created by macOS's built-in file zipper. |
| 145 | if (name.begins_with("__MACOSX")) { |
| 146 | ret = unzGoToNextFile(pkg); |
nothing calls this directly
no test coverage detected