From 356c35954af46ed70790b6f9d75a13714e1144aa Mon Sep 17 00:00:00 2001 From: volzhs Date: Fri, 3 Jun 2016 03:39:37 +0900 Subject: [PATCH] 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 9073dc99634285edc3b4886467871c14100f8233) --- core/os/os.cpp | 9 +++++++++ core/os/os.h | 1 + drivers/unix/os_unix.cpp | 2 +- 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 1aee6d9aa2e..e745578085c 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 invalid_char = String("\\ / : * ? \" < > |").split(" "); + for (int i=0;iget("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 7f5f40b3a05..5cc1c868f76 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -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")) {