Allow existing hidden files/directories when creating a new project
For instance, this lets users initialize a Git repository
and still be able to create a project in the directory afterwards.
This closes https://github.com/godotengine/godot-proposals/issues/291.
(cherry picked from commit 34b747bac0
)
This commit is contained in:
parent
7ccfbd61a4
commit
262aff67db
1 changed files with 17 additions and 9 deletions
|
@ -163,7 +163,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid_path == "") {
|
if (valid_path == "") {
|
||||||
set_message(TTR("The path does not exist."), MESSAGE_ERROR);
|
set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR);
|
||||||
memdelete(d);
|
memdelete(d);
|
||||||
get_ok()->set_disabled(true);
|
get_ok()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
|
@ -177,7 +177,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid_install_path == "") {
|
if (valid_install_path == "") {
|
||||||
set_message(TTR("The path does not exist."), MESSAGE_ERROR, INSTALL_PATH);
|
set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR, INSTALL_PATH);
|
||||||
memdelete(d);
|
memdelete(d);
|
||||||
get_ok()->set_disabled(true);
|
get_ok()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
|
@ -195,7 +195,7 @@ private:
|
||||||
unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io);
|
unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io);
|
||||||
if (!pkg) {
|
if (!pkg) {
|
||||||
|
|
||||||
set_message(TTR("Error opening package file, not in ZIP format."), MESSAGE_ERROR);
|
set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR);
|
||||||
memdelete(d);
|
memdelete(d);
|
||||||
get_ok()->set_disabled(true);
|
get_ok()->set_disabled(true);
|
||||||
unzClose(pkg);
|
unzClose(pkg);
|
||||||
|
@ -216,7 +216,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == UNZ_END_OF_LIST_OF_FILE) {
|
if (ret == UNZ_END_OF_LIST_OF_FILE) {
|
||||||
set_message(TTR("Invalid '.zip' project file, does not contain a 'project.godot' file."), MESSAGE_ERROR);
|
set_message(TTR("Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."), MESSAGE_ERROR);
|
||||||
memdelete(d);
|
memdelete(d);
|
||||||
get_ok()->set_disabled(true);
|
get_ok()->set_disabled(true);
|
||||||
unzClose(pkg);
|
unzClose(pkg);
|
||||||
|
@ -230,7 +230,11 @@ private:
|
||||||
bool is_empty = true;
|
bool is_empty = true;
|
||||||
String n = d->get_next();
|
String n = d->get_next();
|
||||||
while (n != String()) {
|
while (n != String()) {
|
||||||
if (n != "." && n != "..") {
|
if (!n.begins_with(".")) {
|
||||||
|
// Allow `.`, `..` (reserved current/parent folder names)
|
||||||
|
// and hidden files/folders to be present.
|
||||||
|
// For instance, this lets users initialize a Git repository
|
||||||
|
// and still be able to create a project in the directory afterwards.
|
||||||
is_empty = false;
|
is_empty = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +251,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
set_message(TTR("Please choose a 'project.godot' or '.zip' file."), MESSAGE_ERROR);
|
set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR);
|
||||||
memdelete(d);
|
memdelete(d);
|
||||||
install_path_container->hide();
|
install_path_container->hide();
|
||||||
get_ok()->set_disabled(true);
|
get_ok()->set_disabled(true);
|
||||||
|
@ -256,7 +260,7 @@ private:
|
||||||
|
|
||||||
} else if (valid_path.ends_with("zip")) {
|
} else if (valid_path.ends_with("zip")) {
|
||||||
|
|
||||||
set_message(TTR("Directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH);
|
set_message(TTR("This directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH);
|
||||||
memdelete(d);
|
memdelete(d);
|
||||||
get_ok()->set_disabled(true);
|
get_ok()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
|
@ -269,7 +273,11 @@ private:
|
||||||
bool is_empty = true;
|
bool is_empty = true;
|
||||||
String n = d->get_next();
|
String n = d->get_next();
|
||||||
while (n != String()) {
|
while (n != String()) {
|
||||||
if (n != "." && n != "..") { // i don't know if this is enough to guarantee an empty dir
|
if (!n.begins_with(".")) {
|
||||||
|
// Allow `.`, `..` (reserved current/parent folder names)
|
||||||
|
// and hidden files/folders to be present.
|
||||||
|
// For instance, this lets users initialize a Git repository
|
||||||
|
// and still be able to create a project in the directory afterwards.
|
||||||
is_empty = false;
|
is_empty = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +340,7 @@ private:
|
||||||
install_path_container->show();
|
install_path_container->show();
|
||||||
get_ok()->set_disabled(false);
|
get_ok()->set_disabled(false);
|
||||||
} else {
|
} else {
|
||||||
set_message(TTR("Please choose a 'project.godot' or '.zip' file."), MESSAGE_ERROR);
|
set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR);
|
||||||
get_ok()->set_disabled(true);
|
get_ok()->set_disabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue