Blender  V2.59
BLI_path_util.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BLI_path_util.h 36947 2011-05-27 09:57:53Z blendix $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 #ifndef BLI_PATH_UTIL_H
00030 #define BLI_PATH_UTIL_H
00031 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 struct ListBase;
00041 struct direntry;
00042 
00043 const char *BLI_getDefaultDocumentFolder(void);
00044 
00045 char *BLI_get_folder(int folder_id, const char *subfolder);
00046 char *BLI_get_folder_create(int folder_id, const char *subfolder);
00047 char *BLI_get_user_folder_notest(int folder_id, const char *subfolder);
00048 char *BLI_get_folder_version(const int id, const int ver, const int do_check);
00049 
00050 /* folder_id */
00051 
00052 /* general, will find based on user/local/system priority */
00053 #define BLENDER_DATAFILES                       2
00054 
00055 /* user-specific */
00056 #define BLENDER_USER_CONFIG                     31
00057 #define BLENDER_USER_DATAFILES          32
00058 #define BLENDER_USER_SCRIPTS            33
00059 #define BLENDER_USER_PLUGINS            34
00060 #define BLENDER_USER_AUTOSAVE           35
00061 
00062 /* system */
00063 #define BLENDER_SYSTEM_DATAFILES        52
00064 #define BLENDER_SYSTEM_SCRIPTS          53
00065 #define BLENDER_SYSTEM_PLUGINS          54
00066 #define BLENDER_SYSTEM_PYTHON           54
00067 
00068 #define BLENDER_TEMP                            80
00069 
00070 #define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS)
00071 
00072 /* for BLI_get_folder_version only */
00073 #define BLENDER_RESOURCE_PATH_USER              0
00074 #define BLENDER_RESOURCE_PATH_LOCAL             1
00075 #define BLENDER_RESOURCE_PATH_SYSTEM    2
00076 
00077 #define BLENDER_STARTUP_FILE    "startup.blend"
00078 #define BLENDER_BOOKMARK_FILE   "bookmarks.txt"
00079 #define BLENDER_HISTORY_FILE    "recent-files.txt"
00080 
00081 #ifdef WIN32
00082 #define BLENDER_USER_FORMAT             "%s\\Blender Foundation\\Blender\\%s"
00083 #define BLENDER_SYSTEM_FORMAT           "%s\\Blender Foundation\\Blender\\%s"
00084 #elif defined(__APPLE__)
00085 #define BLENDER_USER_FORMAT                     "%s/Blender/%s"
00086 #define BLENDER_SYSTEM_FORMAT                   "%s/Blender/%s"
00087 #else
00088 #define BLENDER_USER_FORMAT                     "%s/.blender/%s"
00089 #define BLENDER_SYSTEM_FORMAT                   "%s/blender/%s"
00090 #endif
00091 
00092 #ifdef WIN32
00093 #define SEP '\\'
00094 #define ALTSEP '/'
00095 #else
00096 #define SEP '/'
00097 #define ALTSEP '\\'
00098 #endif
00099 
00100 void BLI_setenv(const char *env, const char *val);
00101 void BLI_setenv_if_new(const char *env, const char* val);
00102 
00103 void BLI_make_file_string(const char *relabase, char *string,  const char *dir, const char *file);
00104 void BLI_make_exist(char *dir);
00105 void BLI_make_existing_file(const char *name);
00106 void BLI_split_dirfile(const char *string, char *dir, char *file);
00107 void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file);
00108 char *BLI_path_basename(char *path);
00109 int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir);
00110 char *BLI_last_slash(const char *string);
00111 int       BLI_add_slash(char *string);
00112 void  BLI_del_slash(char *string);
00113 char *BLI_first_slash(char *string);
00114 
00115 void BLI_getlastdir(const char* dir, char *last, const size_t maxlen);
00116 int BLI_testextensie(const char *str, const char *ext);
00117 int BLI_testextensie_array(const char *str, const char **ext_array);
00118 int BLI_testextensie_glob(const char *str, const char *ext_fnmatch);
00119 int BLI_replace_extension(char *path, size_t maxlen, const char *ext);
00120 void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len);
00121 int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, const char defname[], char delim, char *name, short name_len);
00122 void BLI_newname(char * name, int add);
00123 int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen);
00124 void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic);
00125 int BLI_split_name_num(char *left, int *nr, const char *name, const char delim);
00126 void BLI_splitdirstring(char *di,char *fi);
00127 
00128 /* make sure path separators conform to system one */
00129 void BLI_clean(char *path);
00130 
00136 void BLI_cleanup_file(const char *relabase, char *dir); /* removes trailing slash */
00137 void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */
00138 void BLI_cleanup_path(const char *relabase, char *dir); /* doesn't touch trailing slash */
00139 
00140 /* go back one directory */
00141 int BLI_parent_dir(char *path);
00142 
00143 /* return whether directory is root and thus has no parent dir */
00144 int BLI_has_parent(char *path);
00145 
00158 int BLI_path_abs(char *path, const char *basepath);
00159 int BLI_path_frame(char *path, int frame, int digits);
00160 int BLI_path_frame_range(char *path, int sta, int end, int digits);
00161 int BLI_path_cwd(char *path);
00162 void BLI_path_rel(char *file, const char *relfile);
00163 
00164 #ifdef WIN32
00165 #  define BLI_path_cmp BLI_strcasecmp
00166 #  define BLI_path_ncmp BLI_strncasecmp
00167 #else
00168 #  define BLI_path_cmp strcmp
00169 #  define BLI_path_ncmp strncmp
00170 #endif
00171 
00180 void BLI_char_switch(char *string, char from, char to);
00181 
00193 void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name);
00194 
00203 void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp);
00204 
00205 
00206 #ifdef WITH_ICONV
00207 void BLI_string_to_utf8(char *original, char *utf_8, const char *code);
00208 #endif
00209 
00210 #ifdef __cplusplus
00211 }
00212 #endif
00213 
00214 #endif
00215