diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2016-06-04 21:37:47 +0200 |
---|---|---|
committer | Rémi Verschelde <remi@verschelde.fr> | 2016-06-04 21:37:47 +0200 |
commit | 2884faf55bfe5bc01c71f1b77d8996300c7597ec (patch) | |
tree | c3cace4d63fc1b80d187064ebd148d4c81fc2f77 | |
parent | 5b6a8eca94301410b066def0303a132bdc833dd4 (diff) | |
parent | 9073dc99634285edc3b4886467871c14100f8233 (diff) |
Merge pull request #4999 from volzhs/fix-project-path
change invalid characters when get user data dir on Windows & Unix
-rw-r--r-- | core/os/os.cpp | 9 | ||||
-rw-r--r-- | core/os/os.h | 1 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 2 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 2 |
4 files changed, 12 insertions, 2 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp index 6910b368d3..4daf41e68e 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -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 "."; diff --git a/core/os/os.h b/core/os/os.h index 76dd235d24..a1047bd48f 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -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; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 4fa46b16cd..8cb7c7b698 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -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!="") { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 4f2bfd46ae..aff48c718c 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -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")) { |