From 9073dc99634285edc3b4886467871c14100f8233 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. --- 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 6910b368d34..4daf41e68e8 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 4f2bfd46ae1..aff48c718c5 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")) {