Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2019-04-26 18:53:55 +0300
committerRay Molenkamp <github@lazydodo.com>2019-04-26 18:53:55 +0300
commit941575b1f7ddbb981a35167c2fda29db4a41cf96 (patch)
tree711ae995d40a0bed5537ff65556124be3fdfea3b /source/blender/blenlib
parent0fddc48fb2b518a4aa031a08ad4f39233c2c6f3c (diff)
Fix T63853: BLI_current_working_dir did not return utf8 encoding on windows.
When running blender in paths with special characters this caused issues.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/storage.c13
1 files changed, 12 insertions, 1 deletions
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
}
/**