change invalid characters when get user data dir on Windows & Unix
Can't create user data folder when project name has ``\ / : * ? " < > |`` characters on OS_Windows & OS_Unix.
So, change it to ``-`` to be able to make folder.
fixes #4928 and it's altanative to #4986.
(cherry picked from commit 9073dc9963
)
This commit is contained in:
parent
ff91f409bf
commit
356c35954a
|
@ -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 ".";
|
||||
|
|
|
@ -319,6 +319,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;
|
||||
|
||||
|
|
|
@ -456,7 +456,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!="") {
|
||||
|
||||
|
||||
|
|
|
@ -2107,7 +2107,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")) {
|
||||
|
|
Loading…
Reference in New Issue