MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _validate_path

Method _validate_path

editor/project_manager/project_dialog.cpp:89–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void 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);

Callers

nothing calls this directly

Calls 15

is_zip_fileFunction · 0.85
zipio_create_ioFunction · 0.85
strip_edgesMethod · 0.80
get_base_dirMethod · 0.80
begins_withMethod · 0.80
path_joinMethod · 0.80
is_relative_pathMethod · 0.80
get_safe_dir_nameMethod · 0.80
ends_withMethod · 0.80
to_lowerMethod · 0.80
createFunction · 0.50
is_emptyMethod · 0.45

Tested by

no test coverage detected