Merge branch 'master' into blender2.8
This commit is contained in:
commit
1e35f4da72
|
@ -69,12 +69,12 @@ static char btempdir_session[FILE_MAX] = ""; /* volatile temporary directory */
|
|||
const char *BKE_appdir_folder_default(void)
|
||||
{
|
||||
#ifndef WIN32
|
||||
const char * const xdg_documents_dir = getenv("XDG_DOCUMENTS_DIR");
|
||||
const char * const xdg_documents_dir = BLI_getenv("XDG_DOCUMENTS_DIR");
|
||||
|
||||
if (xdg_documents_dir)
|
||||
return xdg_documents_dir;
|
||||
|
||||
return getenv("HOME");
|
||||
return BLI_getenv("HOME");
|
||||
#else /* Windows */
|
||||
static char documentfolder[MAXPATHLEN];
|
||||
HRESULT hResult;
|
||||
|
@ -159,7 +159,7 @@ static bool test_path(
|
|||
*/
|
||||
static bool test_env_path(char *path, const char *envvar)
|
||||
{
|
||||
const char *env = envvar ? getenv(envvar) : NULL;
|
||||
const char *env = envvar ? BLI_getenv(envvar) : NULL;
|
||||
if (!env) return false;
|
||||
|
||||
if (BLI_is_dir(env)) {
|
||||
|
@ -236,6 +236,39 @@ static bool is_portable_install(void)
|
|||
return get_path_local(path, sizeof(path), "config", NULL, ver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path of a folder from environment variables
|
||||
*
|
||||
* \param targetpath: String to return path.
|
||||
* \param subfolder_name: optional name of subfolder within folder.
|
||||
* \param envvar: name of environment variable to check folder_name.
|
||||
* \return true if it was able to construct such a path.
|
||||
*/
|
||||
static bool get_path_environment(
|
||||
char *targetpath,
|
||||
size_t targetpath_len,
|
||||
const char *subfolder_name,
|
||||
const char *envvar)
|
||||
{
|
||||
char user_path[FILE_MAX];
|
||||
|
||||
if (test_env_path(user_path, envvar)) {
|
||||
if (subfolder_name) {
|
||||
return test_path(
|
||||
targetpath,
|
||||
targetpath_len,
|
||||
user_path,
|
||||
NULL,
|
||||
subfolder_name);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(targetpath, user_path, FILE_MAX);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path of a folder within the user-files area.
|
||||
*
|
||||
|
@ -243,13 +276,12 @@ static bool is_portable_install(void)
|
|||
* \param targetpath String to return path
|
||||
* \param folder_name default name of folder within user area
|
||||
* \param subfolder_name optional name of subfolder within folder
|
||||
* \param envvar name of environment variable which, if defined, overrides folder_name
|
||||
* \param ver Blender version, used to construct a subdirectory name
|
||||
* \param ver Blender version, used to construct a subdirectory name
|
||||
* \return true if it was able to construct such a path.
|
||||
*/
|
||||
static bool get_path_user(
|
||||
char *targetpath, size_t targetpath_len, const char *folder_name, const char *subfolder_name,
|
||||
const char *envvar, const int ver)
|
||||
const int ver)
|
||||
{
|
||||
char user_path[FILE_MAX];
|
||||
const char *user_base_path;
|
||||
|
@ -260,16 +292,6 @@ static bool get_path_user(
|
|||
}
|
||||
user_path[0] = '\0';
|
||||
|
||||
if (test_env_path(user_path, envvar)) {
|
||||
if (subfolder_name) {
|
||||
return test_path(targetpath, targetpath_len, user_path, NULL, subfolder_name);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(targetpath, user_path, FILE_MAX);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
user_base_path = (const char *)GHOST_getUserDir(ver, blender_version_decimal(ver));
|
||||
if (user_base_path)
|
||||
BLI_strncpy(user_path, user_base_path, FILE_MAX);
|
||||
|
@ -295,13 +317,12 @@ static bool get_path_user(
|
|||
* \param targetpath String to return path
|
||||
* \param folder_name default name of folder within installation area
|
||||
* \param subfolder_name optional name of subfolder within folder
|
||||
* \param envvar name of environment variable which, if defined, overrides folder_name
|
||||
* \param ver Blender version, used to construct a subdirectory name
|
||||
* \return true if it was able to construct such a path.
|
||||
*/
|
||||
static bool get_path_system(
|
||||
char *targetpath, size_t targetpath_len, const char *folder_name, const char *subfolder_name,
|
||||
const char *envvar, const int ver)
|
||||
const int ver)
|
||||
{
|
||||
char system_path[FILE_MAX];
|
||||
const char *system_base_path;
|
||||
|
@ -320,17 +341,6 @@ static bool get_path_system(
|
|||
}
|
||||
|
||||
system_path[0] = '\0';
|
||||
|
||||
if (test_env_path(system_path, envvar)) {
|
||||
if (subfolder_name) {
|
||||
return test_path(targetpath, targetpath_len, system_path, NULL, subfolder_name);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(targetpath, system_path, FILE_MAX);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
system_base_path = (const char *)GHOST_getSystemDir(ver, blender_version_decimal(ver));
|
||||
if (system_base_path)
|
||||
BLI_strncpy(system_path, system_base_path, FILE_MAX);
|
||||
|
@ -367,40 +377,49 @@ const char *BKE_appdir_folder_id_ex(
|
|||
|
||||
switch (folder_id) {
|
||||
case BLENDER_DATAFILES: /* general case */
|
||||
if (get_path_user(path, path_len, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) break;
|
||||
if (get_path_user(path, path_len, "datafiles", subfolder, ver)) break;
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES")) break;
|
||||
if (get_path_local(path, path_len, "datafiles", subfolder, ver)) break;
|
||||
if (get_path_system(path, path_len, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES", ver)) break;
|
||||
if (get_path_system(path, path_len, "datafiles", subfolder, ver)) break;
|
||||
return NULL;
|
||||
|
||||
case BLENDER_USER_DATAFILES:
|
||||
if (get_path_user(path, path_len, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) break;
|
||||
if (get_path_user(path, path_len, "datafiles", subfolder, ver)) break;
|
||||
return NULL;
|
||||
|
||||
case BLENDER_SYSTEM_DATAFILES:
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES")) break;
|
||||
if (get_path_system(path, path_len, "datafiles", subfolder, ver)) break;
|
||||
if (get_path_local(path, path_len, "datafiles", subfolder, ver)) break;
|
||||
if (get_path_system(path, path_len, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES", ver)) break;
|
||||
return NULL;
|
||||
|
||||
case BLENDER_USER_AUTOSAVE:
|
||||
if (get_path_user(path, path_len, "autosave", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) break;
|
||||
if (get_path_user(path, path_len, "autosave", subfolder, ver)) break;
|
||||
return NULL;
|
||||
|
||||
case BLENDER_USER_CONFIG:
|
||||
if (get_path_user(path, path_len, "config", subfolder, "BLENDER_USER_CONFIG", ver)) break;
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_CONFIG")) break;
|
||||
if (get_path_user(path, path_len, "config", subfolder, ver)) break;
|
||||
return NULL;
|
||||
|
||||
case BLENDER_USER_SCRIPTS:
|
||||
if (get_path_user(path, path_len, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break;
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_SCRIPTS")) break;
|
||||
if (get_path_user(path, path_len, "scripts", subfolder, ver)) break;
|
||||
return NULL;
|
||||
|
||||
case BLENDER_SYSTEM_SCRIPTS:
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_SCRIPTS")) break;
|
||||
if (get_path_system(path, path_len, "scripts", subfolder, ver)) break;
|
||||
if (get_path_local(path, path_len, "scripts", subfolder, ver)) break;
|
||||
if (get_path_system(path, path_len, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS", ver)) break;
|
||||
return NULL;
|
||||
|
||||
case BLENDER_SYSTEM_PYTHON:
|
||||
if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_PYTHON")) break;
|
||||
if (get_path_system(path, path_len, "python", subfolder, ver)) break;
|
||||
if (get_path_local(path, path_len, "python", subfolder, ver)) break;
|
||||
if (get_path_system(path, path_len, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break;
|
||||
return NULL;
|
||||
|
||||
default:
|
||||
|
@ -428,16 +447,20 @@ const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char *su
|
|||
|
||||
switch (folder_id) {
|
||||
case BLENDER_USER_DATAFILES:
|
||||
get_path_user(path, sizeof(path), "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver);
|
||||
if (get_path_environment(path, sizeof(path), subfolder, "BLENDER_USER_DATAFILES")) break;
|
||||
get_path_user(path, sizeof(path), "datafiles", subfolder, ver);
|
||||
break;
|
||||
case BLENDER_USER_CONFIG:
|
||||
get_path_user(path, sizeof(path), "config", subfolder, "BLENDER_USER_CONFIG", ver);
|
||||
if (get_path_environment(path, sizeof(path), subfolder, "BLENDER_USER_CONFIG")) break;
|
||||
get_path_user(path, sizeof(path), "config", subfolder, ver);
|
||||
break;
|
||||
case BLENDER_USER_AUTOSAVE:
|
||||
get_path_user(path, sizeof(path), "autosave", subfolder, "BLENDER_USER_AUTOSAVE", ver);
|
||||
if (get_path_environment(path, sizeof(path), subfolder, "BLENDER_USER_AUTOSAVE")) break;
|
||||
get_path_user(path, sizeof(path), "autosave", subfolder, ver);
|
||||
break;
|
||||
case BLENDER_USER_SCRIPTS:
|
||||
get_path_user(path, sizeof(path), "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver);
|
||||
if (get_path_environment(path, sizeof(path), subfolder, "BLENDER_USER_SCRIPTS")) break;
|
||||
get_path_user(path, sizeof(path), "scripts", subfolder, ver);
|
||||
break;
|
||||
default:
|
||||
BLI_assert(0);
|
||||
|
@ -481,13 +504,13 @@ const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, con
|
|||
bool ok;
|
||||
switch (folder_id) {
|
||||
case BLENDER_RESOURCE_PATH_USER:
|
||||
ok = get_path_user(path, sizeof(path), NULL, NULL, NULL, ver);
|
||||
ok = get_path_user(path, sizeof(path), NULL, NULL, ver);
|
||||
break;
|
||||
case BLENDER_RESOURCE_PATH_LOCAL:
|
||||
ok = get_path_local(path, sizeof(path), NULL, NULL, ver);
|
||||
break;
|
||||
case BLENDER_RESOURCE_PATH_SYSTEM:
|
||||
ok = get_path_system(path, sizeof(path), NULL, NULL, NULL, ver);
|
||||
ok = get_path_system(path, sizeof(path), NULL, NULL, ver);
|
||||
break;
|
||||
default:
|
||||
path[0] = '\0'; /* in case do_check is false */
|
||||
|
@ -743,7 +766,7 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
|
|||
|
||||
#ifdef WIN32
|
||||
if (fullname[0] == '\0') {
|
||||
const char *tmp = getenv("TEMP"); /* Windows */
|
||||
const char *tmp = BLI_getenv("TEMP"); /* Windows */
|
||||
if (tmp && BLI_is_dir(tmp)) {
|
||||
BLI_strncpy(fullname, tmp, maxlen);
|
||||
}
|
||||
|
@ -751,14 +774,14 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
|
|||
#else
|
||||
/* Other OS's - Try TMP and TMPDIR */
|
||||
if (fullname[0] == '\0') {
|
||||
const char *tmp = getenv("TMP");
|
||||
const char *tmp = BLI_getenv("TMP");
|
||||
if (tmp && BLI_is_dir(tmp)) {
|
||||
BLI_strncpy(fullname, tmp, maxlen);
|
||||
}
|
||||
}
|
||||
|
||||
if (fullname[0] == '\0') {
|
||||
const char *tmp = getenv("TMPDIR");
|
||||
const char *tmp = BLI_getenv("TMPDIR");
|
||||
if (tmp && BLI_is_dir(tmp)) {
|
||||
BLI_strncpy(fullname, tmp, maxlen);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,10 +1220,27 @@ 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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -214,7 +214,7 @@ void BLT_lang_init(void)
|
|||
*
|
||||
* Would also be good to find nicer way to check if LANG is correct.
|
||||
*/
|
||||
const char *lang = getenv("LANG");
|
||||
const char *lang = BLI_getenv("LANG");
|
||||
if (lang != NULL) {
|
||||
char *old_locale = setlocale(LC_ALL, NULL);
|
||||
/* Make a copy so subsequenct setlocale() doesn't interfere. */
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "DNA_object_fluidsim_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
|
@ -875,8 +876,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
|
|||
|
||||
fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job");
|
||||
|
||||
if (getenv(strEnvName)) {
|
||||
int dlevel = atoi(getenv(strEnvName));
|
||||
if (BLI_getenv(strEnvName)) {
|
||||
int dlevel = atoi(BLI_getenv(strEnvName));
|
||||
elbeemSetDebugLevel(dlevel);
|
||||
BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::msg: Debug messages activated due to envvar '%s'\n", strEnvName);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
|
|
|
@ -575,7 +575,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
|
|||
#else
|
||||
/* unix */
|
||||
{
|
||||
const char *home = getenv("HOME");
|
||||
const char *home = BLI_getenv("HOME");
|
||||
|
||||
if (read_bookmarks && home) {
|
||||
BLI_snprintf(line, sizeof(line), "%s/", home);
|
||||
|
|
|
@ -624,7 +624,7 @@ void colormanagement_init(void)
|
|||
|
||||
OCIO_init();
|
||||
|
||||
ocio_env = getenv("OCIO");
|
||||
ocio_env = BLI_getenv("OCIO");
|
||||
|
||||
if (ocio_env && ocio_env[0] != '\0') {
|
||||
config = OCIO_configCreateFromEnv();
|
||||
|
|
|
@ -99,10 +99,10 @@ static bool get_thumb_dir(char *dir, ThumbSize size)
|
|||
s += strlen(dir);
|
||||
#else
|
||||
#if defined(USE_FREEDESKTOP)
|
||||
const char *home_cache = getenv("XDG_CACHE_HOME");
|
||||
const char *home = home_cache ? home_cache : getenv("HOME");
|
||||
const char *home_cache = BLI_getenv("XDG_CACHE_HOME");
|
||||
const char *home = home_cache ? home_cache : BLI_getenv("HOME");
|
||||
#else
|
||||
const char *home = getenv("HOME");
|
||||
const char *home = BLI_getenv("HOME");
|
||||
#endif
|
||||
if (!home) return 0;
|
||||
s += BLI_strncpy_rlen(s, home, FILE_MAX);
|
||||
|
|
|
@ -479,8 +479,8 @@ static Mesh *fluidsim_read_cache(
|
|||
const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp
|
||||
|
||||
if (G.background == 1) {
|
||||
if (getenv(strEnvName2)) {
|
||||
int elevel = atoi(getenv(strEnvName2));
|
||||
if (BLI_getenv(strEnvName2)) {
|
||||
int elevel = atoi(BLI_getenv(strEnvName2));
|
||||
if (elevel > 0) {
|
||||
printf("Env. var %s set, fluid sim mesh '%s' not found, aborting render...\n",
|
||||
strEnvName2, targetFile);
|
||||
|
|
Loading…
Reference in New Issue