Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/appdir.c
| Show First 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | static bool test_path(char *targetpath, | ||||
| /* Path not found, don't accidentally use it, | /* Path not found, don't accidentally use it, | ||||
| * otherwise call this function with `check_is_dir` set to false. */ | * otherwise call this function with `check_is_dir` set to false. */ | ||||
| targetpath[0] = '\0'; | targetpath[0] = '\0'; | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| * Puts the value of the specified environment variable into *path if it exists | * Puts the value of the specified environment variable into *path if it exists. | ||||
| * and points at a directory. Returns true if this was done. | * Additionally it checks if it points at a directory, when check_is_dir is true. | ||||
| * The return value is true when the value of the environment variable is stored | |||||
| * at the address *path points to. | |||||
| */ | */ | ||||
| static bool test_env_path(char *path, const char *envvar, const bool check_is_dir) | static bool test_env_path(char *path, const char *envvar, const bool check_is_dir) | ||||
| { | { | ||||
| ASSERT_IS_INIT(); | ASSERT_IS_INIT(); | ||||
| const char *env_path = envvar ? BLI_getenv(envvar) : NULL; | const char *env_path = envvar ? BLI_getenv(envvar) : NULL; | ||||
| if (!env_path) { | if (!env_path) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| BLI_strncpy(path, env_path, FILE_MAX); | |||||
| if (check_is_dir == false) { | if (check_is_dir == false) { | ||||
| CLOG_INFO(&LOG, 3, "using env '%s' without test: '%s'", envvar, env_path); | CLOG_INFO(&LOG, 3, "using env '%s' without test: '%s'", envvar, env_path); | ||||
| return true; | return true; | ||||
| } | } | ||||
| if (BLI_is_dir(env_path)) { | if (BLI_is_dir(env_path)) { | ||||
| BLI_strncpy(path, env_path, FILE_MAX); | |||||
| CLOG_INFO(&LOG, 3, "env '%s' found: %s", envvar, env_path); | CLOG_INFO(&LOG, 3, "env '%s' found: %s", envvar, env_path); | ||||
| return true; | return true; | ||||
| } | } | ||||
| CLOG_INFO(&LOG, 3, "env '%s' missing: %s", envvar, env_path); | CLOG_INFO(&LOG, 3, "env '%s' missing: %s", envvar, env_path); | ||||
| /* Path not found, don't accidentally use it, | /* Path not found, don't accidentally use it, | ||||
| * otherwise call this function with `check_is_dir` set to false. */ | * otherwise call this function with `check_is_dir` set to false. */ | ||||
| ▲ Show 20 Lines • Show All 865 Lines • Show Last 20 Lines | |||||