2 * blenlib/BLI_storage_types.h
4 * Some types for dealing with directories
8 * ***** BEGIN GPL LICENSE BLOCK *****
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
25 * All rights reserved.
27 * The Original Code is: all of this file.
29 * Contributor(s): none yet.
31 * ***** END GPL LICENSE BLOCK *****
36 /* XXX doesn't seem to be used, marded for removal
37 #define mallocstructN(x,y,name) (x*)MEM_mallocN((y)* sizeof(x),name)
38 #define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
44 char *BLI_gethome(void);
45 char *BLI_gethome_folder(char *folder_name, int flag);
47 /* BLI_gethome_folder flag */
48 #define BLI_GETHOME_LOCAL 1<<1 /* relative location for portable binaries */
49 #define BLI_GETHOME_SYSTEM 1<<2 /* system location, or set from the BLENDERPATH env variable (UNIX only) */
50 #define BLI_GETHOME_USER 1<<3 /* home folder ~/.blender */
51 #define BLI_GETHOME_ALL (BLI_GETHOME_SYSTEM|BLI_GETHOME_LOCAL|BLI_GETHOME_USER)
53 void BLI_setenv(const char *env, const char *val);
54 void BLI_setenv_if_new(const char *env, const char* val);
56 void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file);
57 void BLI_make_exist(char *dir);
58 void BLI_make_existing_file(char *name);
59 void BLI_split_dirfile(char *string, char *dir, char *file);
60 void BLI_split_dirfile_basic(const char *string, char *dir, char *file);
61 void BLI_join_dirfile(char *string, const char *dir, const char *file);
62 void BLI_getlastdir(const char* dir, char *last, int maxlen);
63 int BLI_testextensie(const char *str, const char *ext);
64 void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len);
65 void BLI_newname(char * name, int add);
66 int BLI_stringdec(char *string, char *kop, char *start, unsigned short *numlen);
67 void BLI_stringenc(char *string, char *kop, char *start, unsigned short numlen, int pic);
68 void BLI_splitdirstring(char *di,char *fi);
70 /* make sure path separators conform to system one */
71 void BLI_clean(char *path);
74 * dir can be any input, like from buttons, and this function
75 * converts it to a regular full path.
76 * Also removes garbage from directory paths, like /../ or double slashes etc
78 void BLI_cleanup_file(const char *relabase, char *dir);
79 void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */
81 /* go back one directory */
82 int BLI_parent_dir(char *path);
84 /* return whether directory is root and thus has no parent dir */
85 int BLI_has_parent(char *path);
88 * Blender's path code replacement function.
89 * Bases @a path strings leading with "//" by the
90 * directory @a basepath, and replaces instances of
91 * '#' with the @a framenum. Results are written
94 * @a path The path to convert
95 * @a basepath The directory to base relative paths with.
96 * @a framenum The framenumber to replace the frame code with.
97 * @retval Returns true if the path was relative (started with "//").
99 int BLI_convertstringcode(char *path, const char *basepath);
100 int BLI_convertstringframe(char *path, int frame);
101 int BLI_convertstringcwd(char *path);
103 void BLI_makestringcode(const char *relfile, char *file);
106 * Change every @a from in @a string into @a to. The
107 * result will be in @a string
109 * @a string The string to work on
110 * @a from The character to replace
111 * @a to The character to replace with
113 void BLI_char_switch(char *string, char from, char to);
116 * Checks if name is a fully qualified filename to an executable.
117 * If not it searches $PATH for the file. On Windows it also
118 * adds the correct extension (.com .exe etc) from
119 * $PATHEXT if necessary. Also on Windows it translates
120 * the name to its 8.3 version to prevent problems with
121 * spaces and stuff. Final result is returned in fullname.
123 * @param fullname The full path and full name of the executable
124 * @param name The name of the executable (usually argv[0]) to be checked
126 void BLI_where_am_i(char *fullname, const char *name);
128 char *get_install_dir(void);
130 * Gets the temp directory when blender first runs.
131 * If the default path is not found, use try $TEMP
133 * Also make sure the temp dir has a trailing slash
135 * @param fullname The full path to the temp directory
137 void BLI_where_is_temp(char *fullname, int usertemp);
141 * determines the full path to the application bundle on OS X
143 * @return path to application bundle
146 char* BLI_getbundle(void);
150 void BLI_string_to_utf8(char *original, char *utf_8, const char *code);