diff options
author | Andrea Weikert <elubie@gmx.net> | 2010-07-16 00:02:53 +0400 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2010-07-16 00:02:53 +0400 |
commit | 05fb497f75aef331aa708945af5feb69e5169e7b (patch) | |
tree | d9733b5827555f26cf397b0b1e2d50ad56a8e00d /source/blender | |
parent | 7fc9eee08afe87f3f688e8b9e9442951d6a08590 (diff) |
== installation paths ==
remove deprecated python BLI_gethome_folder calls
Patch by Brecht, thanks a lot
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 25 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 115 | ||||
-rw-r--r-- | source/blender/python/intern/bpy.c | 30 |
3 files changed, 10 insertions, 160 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 316b850805d..57e6d0b16d7 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -41,31 +41,6 @@ struct ListBase; struct direntry; char *BLI_gethome(void); -char *BLI_gethome_folder(char *folder_name, int flag); - -/* BLI_gethome_folder flag */ -#define BLI_GETHOME_LOCAL 1<<1 /* relative location for portable binaries */ -#define BLI_GETHOME_SYSTEM 1<<2 /* system location, or set from the BLENDERPATH env variable (UNIX only) */ -#define BLI_GETHOME_USER 1<<3 /* home folder ~/.blender */ -#define BLI_GETHOME_ALL (BLI_GETHOME_SYSTEM|BLI_GETHOME_LOCAL|BLI_GETHOME_USER) - - -#ifdef __APPLE__ -typedef enum { - BasePath_Temporary = 1, - BasePath_BlenderShared, - BasePath_BlenderUser, - BasePath_ApplicationBundle -} basePathesTypes; - -/** - * Gets the base path. The path may not exist. - * Note that return string must be copied as its persistence is not guaranteed - * - * @return base path of pathType - */ -const char* BLI_osx_getBasePath(basePathesTypes pathType); -#endif char *BLI_get_folder(int folder_id, char *subfolder); char *BLI_get_folder_create(int folder_id, char *subfolder); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index c1e0059e954..6ab7ba2a7a5 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -795,121 +795,6 @@ char *BLI_gethome(void) { #endif } -/* this function returns the path to a blender folder, if it exists - * utility functions for BLI_gethome_folder */ - -// #define PATH_DEBUG /* for testing paths that are checked */ - -static int test_data_path(char *targetpath, char *path_base, char *path_sep, char *folder_name) -{ - char tmppath[FILE_MAXDIR]; - - if(path_sep) BLI_join_dirfile(tmppath, path_base, path_sep); - else BLI_strncpy(tmppath, path_base, sizeof(tmppath)); - - BLI_make_file_string("/", targetpath, tmppath, folder_name); - - if (BLI_is_dir(targetpath)) { -#ifdef PATH_DEBUG - printf("\tpath found: %s\n", targetpath); -#endif - return 1; - } - else { -#ifdef PATH_DEBUG - printf("\tpath missing: %s\n", targetpath); -#endif - targetpath[0] = '\0'; - return 0; - } -} - -static int gethome_path_local(char *targetpath, char *folder_name) -{ - extern char bprogname[]; /* argv[0] from creator.c */ - char bprogdir[FILE_MAXDIR]; - char cwd[FILE_MAXDIR]; - char *s; - int i; - -#ifdef PATH_DEBUG - printf("gethome_path_local...\n"); -#endif - - /* try release/folder_name (binary relative) */ - /* use argv[0] (bprogname) to get the path to the executable */ - s = BLI_last_slash(bprogname); - i = s - bprogname + 1; - BLI_strncpy(bprogdir, bprogname, i); - - /* try release/folder_name (BIN relative) */ - if(test_data_path(targetpath, bprogdir, "release", folder_name)) - return 1; - - /* try release/folder_name (CWD relative) */ - if(test_data_path(targetpath, BLI_getwdN(cwd), "release", folder_name)) - return 1; - - /* try ./.blender/folder_name */ - if(test_data_path(targetpath, bprogdir, ".blender", folder_name)) - return 1; - - return 0; -} - -static int gethome_path_user(char *targetpath, char *folder_name) -{ - char *home_path= BLI_gethome(); - -#ifdef PATH_DEBUG - printf("gethome_path_user...\n"); -#endif - - /* try $HOME/folder_name */ - return test_data_path(targetpath, home_path, ".blender", folder_name); -} - -static int gethome_path_system(char *targetpath, char *folder_name) -{ - extern char blender_path[]; /* unix prefix eg. /usr/share/blender/2.5 creator.c */ - - if(!blender_path[0]) - return 0; - -#ifdef PATH_DEBUG - printf("gethome_path_system...\n"); -#endif - - /* try $BLENDERPATH/folder_name */ - return test_data_path(targetpath, blender_path, NULL, folder_name); -} - -char *BLI_gethome_folder(char *folder_name, int flag) -{ - static char fulldir[FILE_MAXDIR] = ""; - - /* first check if this is a redistributable bundle */ - if(flag & BLI_GETHOME_LOCAL) { - if (gethome_path_local(fulldir, folder_name)) - return fulldir; - } - - /* then check if the OS has blender data files installed in a global location */ - if(flag & BLI_GETHOME_SYSTEM) { - if (gethome_path_system(fulldir, folder_name)) - return fulldir; - } - - /* now check the users home dir for data files */ - if(flag & BLI_GETHOME_USER) { - if (gethome_path_user(fulldir, folder_name)) - return fulldir; - } - - return NULL; -} - - /* NEW stuff, to be cleaned up when fully migrated */ /* ************************************************************* */ /* ************************************************************* */ diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index b978e46f6da..15be6174f29 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -41,33 +41,23 @@ #include "../generic/blf_api.h" #include "../generic/IDProp.h" -static char bpy_home_paths_doc[] = -".. function:: home_paths(subfolder)\n" +static char bpy_script_paths_doc[] = +".. function:: script_paths()\n" "\n" -" Return 3 paths to blender home directories.\n" +" Return 2 paths to blender scripts directories.\n" "\n" -" :arg subfolder: The name of a subfolder to find within the blenders home directory.\n" -" :type subfolder: string\n" -" :return: (system, local, user) strings will be empty when not found.\n" +" :return: (system, user) strings will be empty when not found.\n" " :rtype: tuple of strigs\n"; -PyObject *bpy_home_paths(PyObject *self, PyObject *args) +PyObject *bpy_script_paths(PyObject *self) { - PyObject *ret= PyTuple_New(3); + PyObject *ret= PyTuple_New(2); char *path; - char *subfolder= ""; - if (!PyArg_ParseTuple(args, "|s:blender_homes", &subfolder)) - return NULL; - - path= BLI_gethome_folder(subfolder, BLI_GETHOME_SYSTEM); + path= BLI_get_folder(BLENDER_USER_SCRIPTS, NULL); PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(path?path:"")); - - path= BLI_gethome_folder(subfolder, BLI_GETHOME_LOCAL); + path= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL); PyTuple_SET_ITEM(ret, 1, PyUnicode_FromString(path?path:"")); - - path= BLI_gethome_folder(subfolder, BLI_GETHOME_USER); - PyTuple_SET_ITEM(ret, 2, PyUnicode_FromString(path?path:"")); return ret; } @@ -120,7 +110,7 @@ static PyObject *bpy_blend_paths(PyObject * self, PyObject *args, PyObject *kw) return list; } -static PyMethodDef meth_bpy_home_paths[] = {{ "home_paths", (PyCFunction)bpy_home_paths, METH_VARARGS, bpy_home_paths_doc}}; +static PyMethodDef meth_bpy_script_paths[] = {{ "script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc}}; static PyMethodDef meth_bpy_blend_paths[] = {{ "blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS|METH_KEYWORDS, bpy_blend_paths_doc}}; static void bpy_import_test(char *modname) @@ -191,7 +181,7 @@ void BPy_init_modules( void ) PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module); /* utility func's that have nowhere else to go */ - PyModule_AddObject(mod, meth_bpy_home_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_home_paths, NULL)); + PyModule_AddObject(mod, meth_bpy_script_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_script_paths, NULL)); PyModule_AddObject(mod, meth_bpy_blend_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_blend_paths, NULL)); /* add our own modules dir, this is a python package */ |