[Bf-blender-cvs] [941575b1f7d] master: Fix T63853: BLI_current_working_dir did not return utf8 encoding on windows.
Ray Molenkamp
noreply at git.blender.org
Fri Apr 26 17:53:59 CEST 2019
Commit: 941575b1f7ddbb981a35167c2fda29db4a41cf96
Author: Ray Molenkamp
Date: Fri Apr 26 09:53:55 2019 -0600
Branches: master
https://developer.blender.org/rB941575b1f7ddbb981a35167c2fda29db4a41cf96
Fix T63853: BLI_current_working_dir did not return utf8 encoding on windows.
When running blender in paths with special characters this caused issues.
===================================================================
M source/blender/blenlib/intern/storage.c
===================================================================
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 <io.h>
# include <direct.h>
+# include <stdbool.h>
# include "BLI_winstuff.h"
+# include "BLI_string_utf8.h"
# include "utfconv.h"
#else
# include <sys/ioctl.h>
@@ -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
}
/**
More information about the Bf-blender-cvs
mailing list