Merge pull request #4999 from volzhs/fix-project-path

change invalid characters when get user data dir on Windows & Unix
This commit is contained in:
Rémi Verschelde 2016-06-04 21:37:47 +02:00
commit 2884faf55b
4 changed files with 12 additions and 2 deletions

View file

@ -306,6 +306,15 @@ String OS::get_system_dir(SystemDir p_dir) const {
return ".";
}
String OS::get_safe_application_name() const {
String an = Globals::get_singleton()->get("application/name");
Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" ");
for (int i=0;i<invalid_char.size();i++) {
an = an.replace(invalid_char[i],"-");
}
return an;
}
String OS::get_data_dir() const {
return ".";

View file

@ -326,6 +326,7 @@ public:
virtual String get_locale() const;
String get_safe_application_name() const;
virtual String get_data_dir() const;
virtual String get_resource_dir() const;

View file

@ -464,7 +464,7 @@ int OS_Unix::get_processor_count() const {
String OS_Unix::get_data_dir() const {
String an = Globals::get_singleton()->get("application/name");
String an = get_safe_application_name();
if (an!="") {

View file

@ -2243,7 +2243,7 @@ String OS_Windows::get_system_dir(SystemDir p_dir) const {
}
String OS_Windows::get_data_dir() const {
String an = Globals::get_singleton()->get("application/name");
String an = get_safe_application_name();
if (an!="") {
if (has_environment("APPDATA")) {