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>2018-09-05 07:31:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-05 07:32:19 +0300
commitc13b2a2504393371e32a4fb4c01cfad8d7cc929e (patch)
treea07973eeff324519187c23cd6b52f61da10d83a3 /source/blender/blenlib
parentbb6a94fa7b28390ea8c22a6026562b0ab6685f92 (diff)
Fix T54152: --env-system-scripts fails on win32
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_path_util.h1
-rw-r--r--source/blender/blenlib/intern/path_util.c23
-rw-r--r--source/blender/blenlib/intern/storage.c2
3 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index b4329bf81ac..e434e83416b 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -41,6 +41,7 @@ struct ListBase;
void BLI_setenv(const char *env, const char *val) ATTR_NONNULL(1);
void BLI_setenv_if_new(const char *env, const char *val) ATTR_NONNULL(1);
+const char *BLI_getenv(const char *env) ATTR_NONNULL(1);
void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file);
void BLI_make_exist(char *dir);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 6272f2109d2..b28579febaf 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1095,7 +1095,7 @@ bool BLI_path_program_extensions_add_win32(char *name, const size_t maxlen)
if ((type == 0) || S_ISDIR(type)) {
/* typically 3-5, ".EXE", ".BAT"... etc */
const int ext_max = 12;
- const char *ext = getenv("PATHEXT");
+ const char *ext = BLI_getenv("PATHEXT");
if (ext) {
const int name_len = strlen(name);
char *filename = alloca(name_len + ext_max);
@@ -1152,7 +1152,7 @@ bool BLI_path_program_search(
const char separator = ':';
#endif
- path = getenv("PATH");
+ path = BLI_getenv("PATH");
if (path) {
char filename[FILE_MAX];
const char *temp;
@@ -1220,11 +1220,28 @@ void BLI_setenv(const char *env, const char *val)
*/
void BLI_setenv_if_new(const char *env, const char *val)
{
- if (getenv(env) == NULL)
+ if (BLI_getenv(env) == NULL)
BLI_setenv(env, val);
}
/**
+* get an env var, result has to be used immediately
+*/
+const char* BLI_getenv(const char *env)
+{
+#ifdef _MSC_VER
+ static char buffer[32767]; /* 32767 is the total size of the environment block on windows*/
+ if (GetEnvironmentVariableA(env, buffer, sizeof(buffer)))
+ return buffer;
+ else
+ return NULL;
+#else
+ return getenv(env);
+#endif
+}
+
+
+/**
* Strips off nonexistent (or non-accessible) subdirectories from the end of *dir, leaving the path of
* the lowest-level directory that does exist and we can read.
*/
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index f69b35ce5a9..cfcc2bc4390 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -85,7 +85,7 @@
*/
char *BLI_current_working_dir(char *dir, const size_t maxncpy)
{
- const char *pwd = getenv("PWD");
+ const char *pwd = BLI_getenv("PWD");
if (pwd) {
size_t srclen = BLI_strnlen(pwd, maxncpy);
if (srclen != maxncpy) {