Blender V2.61 - r43446

BLI_path_util.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 #ifndef BLI_PATH_UTIL_H
00028 #define BLI_PATH_UTIL_H
00029 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 struct ListBase;
00039 struct direntry;
00040 
00041 const char *BLI_getDefaultDocumentFolder(void);
00042 
00043 char *BLI_get_folder(int folder_id, const char *subfolder);
00044 char *BLI_get_folder_create(int folder_id, const char *subfolder);
00045 char *BLI_get_user_folder_notest(int folder_id, const char *subfolder);
00046 char *BLI_get_folder_version(const int id, const int ver, const int do_check);
00047 
00048 /* folder_id */
00049 
00050 /* general, will find based on user/local/system priority */
00051 #define BLENDER_DATAFILES           2
00052 
00053 /* user-specific */
00054 #define BLENDER_USER_CONFIG         31
00055 #define BLENDER_USER_DATAFILES      32
00056 #define BLENDER_USER_SCRIPTS        33
00057 #define BLENDER_USER_PLUGINS        34
00058 #define BLENDER_USER_AUTOSAVE       35
00059 
00060 /* system */
00061 #define BLENDER_SYSTEM_DATAFILES    52
00062 #define BLENDER_SYSTEM_SCRIPTS      53
00063 #define BLENDER_SYSTEM_PLUGINS      54
00064 #define BLENDER_SYSTEM_PYTHON       54
00065 
00066 /* for BLI_get_folder_version only */
00067 #define BLENDER_RESOURCE_PATH_USER      0
00068 #define BLENDER_RESOURCE_PATH_LOCAL     1
00069 #define BLENDER_RESOURCE_PATH_SYSTEM    2
00070 
00071 #define BLENDER_STARTUP_FILE    "startup.blend"
00072 #define BLENDER_BOOKMARK_FILE   "bookmarks.txt"
00073 #define BLENDER_HISTORY_FILE    "recent-files.txt"
00074 
00075 #ifdef WIN32
00076 #define SEP '\\'
00077 #define ALTSEP '/'
00078 #else
00079 #define SEP '/'
00080 #define ALTSEP '\\'
00081 #endif
00082 
00083 void BLI_setenv(const char *env, const char *val);
00084 void BLI_setenv_if_new(const char *env, const char* val);
00085 
00086 void BLI_make_file_string(const char *relabase, char *string,  const char *dir, const char *file);
00087 void BLI_make_exist(char *dir);
00088 void BLI_make_existing_file(const char *name);
00089 void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen);
00090 void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen);
00091 void BLI_split_file_part(const char *string, char *file, const size_t filelen);
00092 void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file);
00093 char *BLI_path_basename(char *path);
00094 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);
00095 char *BLI_last_slash(const char *string);
00096 int   BLI_add_slash(char *string);
00097 void  BLI_del_slash(char *string);
00098 char *BLI_first_slash(char *string);
00099 
00100 void BLI_getlastdir(const char* dir, char *last, const size_t maxlen);
00101 int BLI_testextensie(const char *str, const char *ext);
00102 int BLI_testextensie_array(const char *str, const char **ext_array);
00103 int BLI_testextensie_glob(const char *str, const char *ext_fnmatch);
00104 int BLI_replace_extension(char *path, size_t maxlen, const char *ext);
00105 int BLI_ensure_extension(char *path, size_t maxlen, const char *ext);
00106 void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len);
00107 int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, const char defname[], char delim, char *name, short name_len);
00108 void BLI_newname(char * name, int add);
00109 int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen);
00110 void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic);
00111 int BLI_split_name_num(char *left, int *nr, const char *name, const char delim);
00112 void BLI_splitdirstring(char *di,char *fi);
00113 
00114 /* make sure path separators conform to system one */
00115 void BLI_clean(char *path);
00116 
00122 void BLI_cleanup_file(const char *relabase, char *dir); /* removes trailing slash */
00123 void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */
00124 void BLI_cleanup_path(const char *relabase, char *dir); /* doesn't touch trailing slash */
00125 
00126 /* go back one directory */
00127 int BLI_parent_dir(char *path);
00128 
00129 /* return whether directory is root and thus has no parent dir */
00130 int BLI_has_parent(char *path);
00131 
00144 int BLI_path_abs(char *path, const char *basepath);
00145 int BLI_path_frame(char *path, int frame, int digits);
00146 int BLI_path_frame_range(char *path, int sta, int end, int digits);
00147 int BLI_path_cwd(char *path);
00148 void BLI_path_rel(char *file, const char *relfile);
00149 
00150 #ifdef WIN32
00151 #  define BLI_path_cmp BLI_strcasecmp
00152 #  define BLI_path_ncmp BLI_strncasecmp
00153 #else
00154 #  define BLI_path_cmp strcmp
00155 #  define BLI_path_ncmp strncmp
00156 #endif
00157 
00166 void BLI_char_switch(char *string, char from, char to);
00167 
00168     /* Initialize path to program executable */
00169 void BLI_init_program_path(const char *argv0);
00170     /* Initialize path to temporary directory.
00171      * NOTE: On Window userdir will be set to the temporary directory! */
00172 void BLI_init_temporary_dir(char *userdir);
00173 
00174     /* Path to executable */
00175 const char *BLI_program_path(void);
00176     /* Path to directory of executable */
00177 const char *BLI_program_dir(void);
00178     /* Path to temporary directory (with trailing slash) */
00179 const char *BLI_temporary_dir(void);
00180     /* Path to the system temporary directory (with trailing slash) */
00181 void BLI_system_temporary_dir(char *dir);
00182 
00183 #ifdef WITH_ICONV
00184 void BLI_string_to_utf8(char *original, char *utf_8, const char *code);
00185 #endif
00186 
00187 #ifdef __cplusplus
00188 }
00189 #endif
00190 
00191 #endif
00192