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);
47 void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file);
48 void BLI_make_exist(char *dir);
49 void BLI_make_existing_file(char *name);
50 void BLI_split_dirfile(char *string, char *dir, char *file);
51 void BLI_split_dirfile_basic(const char *string, char *dir, char *file);
52 void BLI_join_dirfile(char *string, const char *dir, const char *file);
53 void BLI_getlastdir(const char* dir, char *last, int maxlen);
54 int BLI_testextensie(const char *str, const char *ext);
55 void BLI_uniquename(struct ListBase *list, void *vlink, char defname[], char delim, short name_offs, short len);
56 void BLI_newname(char * name, int add);
57 int BLI_stringdec(char *string, char *kop, char *start, unsigned short *numlen);
58 void BLI_stringenc(char *string, char *kop, char *start, unsigned short numlen, int pic);
59 void BLI_splitdirstring(char *di,char *fi);
61 /* make sure path separators conform to system one */
62 void BLI_clean(char *path);
65 * dir can be any input, like from buttons, and this function
66 * converts it to a regular full path.
67 * Also removes garbage from directory paths, like /../ or double slashes etc
69 void BLI_cleanup_file(const char *relabase, char *dir);
70 void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */
72 /* go back one directory */
73 int BLI_parent_dir(char *path);
76 * Blender's path code replacement function.
77 * Bases @a path strings leading with "//" by the
78 * directory @a basepath, and replaces instances of
79 * '#' with the @a framenum. Results are written
82 * @a path The path to convert
83 * @a basepath The directory to base relative paths with.
84 * @a framenum The framenumber to replace the frame code with.
85 * @retval Returns true if the path was relative (started with "//").
87 int BLI_convertstringcode(char *path, const char *basepath);
88 int BLI_convertstringframe(char *path, int frame);
89 int BLI_convertstringcwd(char *path);
91 void BLI_makestringcode(const char *relfile, char *file);
94 * Change every @a from in @a string into @a to. The
95 * result will be in @a string
97 * @a string The string to work on
98 * @a from The character to replace
99 * @a to The character to replace with
101 void BLI_char_switch(char *string, char from, char to);
104 * Checks if name is a fully qualified filename to an executable.
105 * If not it searches $PATH for the file. On Windows it also
106 * adds the correct extension (.com .exe etc) from
107 * $PATHEXT if necessary. Also on Windows it translates
108 * the name to its 8.3 version to prevent problems with
109 * spaces and stuff. Final result is returned in fullname.
111 * @param fullname The full path and full name of the executable
112 * @param name The name of the executable (usually argv[0]) to be checked
114 void BLI_where_am_i(char *fullname, const char *name);
116 char *get_install_dir(void);
118 * Gets the temp directory when blender first runs.
119 * If the default path is not found, use try $TEMP
121 * Also make sure the temp dir has a trailing slash
123 * @param fullname The full path to the temp directory
125 void BLI_where_is_temp(char *fullname, int usertemp);
129 * determines the full path to the application bundle on OS X
131 * @return path to application bundle
134 char* BLI_getbundle(void);
138 void BLI_string_to_utf8(char *original, char *utf_8, const char *code);