diff options
Diffstat (limited to 'source/blender/blenlib/BLI_path_util.h')
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 105 |
1 files changed, 81 insertions, 24 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 9b4084aa172..316b850805d 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -30,13 +30,12 @@ * * ***** END GPL LICENSE BLOCK ***** */ -#ifndef BLI_UTIL_H -#define BLI_UTIL_H +#ifndef BLI_PATH_UTIL_H +#define BLI_PATH_UTIL_H -/* XXX doesn't seem to be used, marded for removal -#define mallocstructN(x,y,name) (x*)MEM_mallocN((y)* sizeof(x),name) -#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name) -*/ +#ifdef __cplusplus +extern "C" { +#endif struct ListBase; struct direntry; @@ -50,22 +49,85 @@ char *BLI_gethome_folder(char *folder_name, int flag); #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); + +/* folder_id */ + +/* general, will find baserd on user/local/system priority */ +#define BLENDER_CONFIG 1 +#define BLENDER_DATAFILES 2 +#define BLENDER_SCRIPTS 3 +#define BLENDER_PLUGINS 4 +#define BLENDER_PYTHON 5 + +/* user-specific */ +#define BLENDER_USER_CONFIG 31 +#define BLENDER_USER_DATAFILES 32 +#define BLENDER_USER_SCRIPTS 33 +#define BLENDER_USER_PLUGINS 34 + +/* system */ +#define BLENDER_SYSTEM_CONFIG 51 /* optional */ +#define BLENDER_SYSTEM_DATAFILES 52 +#define BLENDER_SYSTEM_SCRIPTS 53 +#define BLENDER_SYSTEM_PLUGINS 54 +#define BLENDER_SYSTEM_PYTHON 54 + +#define BLENDER_TEMP 80 + +#define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS) + +#define BLENDER_STARTUP_FILE "startup.blend" +#define BLENDER_BOOKMARK_FILE "bookmarks.txt" +#define BLENDER_HISTORY_FILE "recent-files.txt" + +#ifdef WIN32 +#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s" +#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s" +#elif __APPLE__ +#define BLENDER_USER_FORMAT "%s/Blender/%s" +#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s" +#else +#define BLENDER_USER_FORMAT "%s/.blender/%s" +#define BLENDER_SYSTEM_FORMAT "%s/blender/%s" +#endif + void BLI_setenv(const char *env, const char *val); void BLI_setenv_if_new(const char *env, const char* val); void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file); void BLI_make_exist(char *dir); void BLI_make_existing_file(char *name); -void BLI_split_dirfile(char *string, char *dir, char *file); -void BLI_split_dirfile_basic(const char *string, char *dir, char *file); +void BLI_split_dirfile(const char *string, char *dir, char *file); void BLI_join_dirfile(char *string, const char *dir, const char *file); +char *BLI_path_basename(char *path); int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char *base_dir, const char *src_dir, const char *dest_dir); void BLI_getlastdir(const char* dir, char *last, int maxlen); int BLI_testextensie(const char *str, const char *ext); +int BLI_replace_extension(char *path, int maxlen, const char *ext); void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len); void BLI_newname(char * name, int add); -int BLI_stringdec(char *string, char *head, char *start, unsigned short *numlen); -void BLI_stringenc(char *string, char *head, char *start, unsigned short numlen, int pic); +int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen); +void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic); void BLI_splitdirstring(char *di,char *fi); /* make sure path separators conform to system one */ @@ -97,12 +159,12 @@ int BLI_has_parent(char *path); * @a framenum The framenumber to replace the frame code with. * @retval Returns true if the path was relative (started with "//"). */ -int BLI_convertstringcode(char *path, const char *basepath); -int BLI_convertstringframe(char *path, int frame, int digits); -int BLI_convertstringframe_range(char *path, int sta, int end, int digits); -int BLI_convertstringcwd(char *path); +int BLI_path_abs(char *path, const char *basepath); +int BLI_path_frame(char *path, int frame, int digits); +int BLI_path_frame_range(char *path, int sta, int end, int digits); +int BLI_path_cwd(char *path); -void BLI_makestringcode(const char *relfile, char *file); +void BLI_path_rel(char *file, const char *relfile); /** * Change every @a from in @a string into @a to. The @@ -139,18 +201,13 @@ char *get_install_dir(void); void BLI_where_is_temp(char *fullname, int usertemp); - /** - * determines the full path to the application bundle on OS X - * - * @return path to application bundle - */ -#ifdef __APPLE__ -char* BLI_getbundle(void); -#endif - #ifdef WITH_ICONV void BLI_string_to_utf8(char *original, char *utf_8, const char *code); #endif +#ifdef __cplusplus +} +#endif + #endif |