From 941575b1f7ddbb981a35167c2fda29db4a41cf96 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Fri, 26 Apr 2019 09:53:55 -0600 Subject: Fix T63853: BLI_current_working_dir did not return utf8 encoding on windows. When running blender in paths with special characters this caused issues. --- source/blender/blenlib/intern/storage.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 64b8ff40bcf..b34a9c0a44e 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -52,7 +52,9 @@ #ifdef WIN32 # include # include +# include # include "BLI_winstuff.h" +# include "BLI_string_utf8.h" # include "utfconv.h" #else # include @@ -77,6 +79,15 @@ */ char *BLI_current_working_dir(char *dir, const size_t maxncpy) { +#if defined(WIN32) + wchar_t path[MAX_PATH]; + if (_wgetcwd(path, MAX_PATH)) { + if (BLI_strncpy_wchar_as_utf8(dir, path, maxncpy) != maxncpy) { + return dir; + } + } + return NULL; +#else const char *pwd = BLI_getenv("PWD"); if (pwd) { size_t srclen = BLI_strnlen(pwd, maxncpy); @@ -88,8 +99,8 @@ char *BLI_current_working_dir(char *dir, const size_t maxncpy) return NULL; } } - return getcwd(dir, maxncpy); +#endif } /** -- cgit v1.2.3