/** * Constructs in \a targetpath the name of a directory relative to a version-specific * subdirectory in the parent directory of the Blender executable. * * \param targetpath String to return path * \param folder_name Optional folder name within version-specific directory * \param subfolder_name Optional subfolder name within folder_name * \param ver To construct name of version-specific directory within bprogdir * \return true if such a directory exists. */ static bool get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name, const int ver) { char relfolder[FILE_MAX]; #ifdef PATH_DEBUG printf("%s...\n", __func__); #endif if (folder_name) { if (subfolder_name) { BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name); } else { BLI_strncpy(relfolder, folder_name, sizeof(relfolder)); } } else { relfolder[0] = '\0'; } /* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */ #ifdef __APPLE__ static char osx_resourses[FILE_MAX]; /* due new codesign situation in OSX > 10.9.5 we must move the blender_version dir with contents to Resources */ sprintf(osx_resourses, "%s../Resources", bprogdir); return test_path(targetpath, osx_resourses, blender_version_decimal(ver), relfolder); #else return test_path(targetpath, bprogdir, blender_version_decimal(ver), relfolder); #endif }
static int get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name, const int ver) { char relfolder[FILE_MAX]; #ifdef PATH_DEBUG2 printf("get_path_local...\n"); #endif if (folder_name) { if (subfolder_name) { BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name); } else { BLI_strncpy(relfolder, folder_name, sizeof(relfolder)); } } else { relfolder[0] = '\0'; } /* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */ if (test_path(targetpath, bprogdir, blender_version_decimal(ver), relfolder)) return 1; return 0; }
static int get_path_user(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver) { char user_path[FILE_MAX]; const char *user_base_path; /* for portable install, user path is always local */ if (is_portable_install()) return get_path_local(targetpath, folder_name, subfolder_name, ver); user_path[0] = '\0'; if (test_env_path(user_path, envvar)) { if (subfolder_name) { return test_path(targetpath, user_path, NULL, subfolder_name); } else { BLI_strncpy(targetpath, user_path, FILE_MAX); return 1; } } 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); if (!user_path[0]) return 0; #ifdef PATH_DEBUG2 printf("get_path_user: %s\n", user_path); #endif if (subfolder_name) { /* try $HOME/folder_name/subfolder_name */ return test_path(targetpath, user_path, folder_name, subfolder_name); } else { /* try $HOME/folder_name */ return test_path(targetpath, user_path, NULL, folder_name); } }
static int get_path_system(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver) { char system_path[FILE_MAX]; const char *system_base_path; /* first allow developer only overrides to the system path * these are only used when running blender from source */ char cwd[FILE_MAX]; char relfolder[FILE_MAX]; if (folder_name) { if (subfolder_name) { BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name); } else { BLI_strncpy(relfolder, folder_name, sizeof(relfolder)); } } else { relfolder[0] = '\0'; } /* try CWD/release/folder_name */ if (BLI_current_working_dir(cwd, sizeof(cwd))) { if (test_path(targetpath, cwd, "release", relfolder)) { return 1; } } /* try EXECUTABLE_DIR/release/folder_name */ if (test_path(targetpath, bprogdir, "release", relfolder)) return 1; /* end developer overrides */ system_path[0] = '\0'; if (test_env_path(system_path, envvar)) { if (subfolder_name) { return test_path(targetpath, system_path, NULL, subfolder_name); } else { BLI_strncpy(targetpath, system_path, FILE_MAX); return 1; } } 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); if (!system_path[0]) return 0; #ifdef PATH_DEBUG2 printf("get_path_system: %s\n", system_path); #endif if (subfolder_name) { /* try $BLENDERPATH/folder_name/subfolder_name */ return test_path(targetpath, system_path, folder_name, subfolder_name); } else { /* try $BLENDERPATH/folder_name */ return test_path(targetpath, system_path, NULL, folder_name); } }