diff options
author | Ray Molenkamp <github@lazydodo.com> | 2018-09-05 07:31:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-09-05 07:32:19 +0300 |
commit | c13b2a2504393371e32a4fb4c01cfad8d7cc929e (patch) | |
tree | a07973eeff324519187c23cd6b52f61da10d83a3 /source/blender/blenlib/intern/path_util.c | |
parent | bb6a94fa7b28390ea8c22a6026562b0ab6685f92 (diff) |
Fix T54152: --env-system-scripts fails on win32
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 23 |
1 files changed, 20 insertions, 3 deletions
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. */ |