| 
									
										
										
										
											2011-02-18 13:58:08 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): none yet. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-02-17 18:59:41 +00:00
										 |  |  | #ifndef __BLI_PATH_UTIL_H__
 | 
					
						
							|  |  |  | #define __BLI_PATH_UTIL_H__
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-18 13:58:08 +00:00
										 |  |  | /** \file BLI_path_util.h
 | 
					
						
							|  |  |  |  *  \ingroup bli | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-04 16:20:42 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | struct ListBase; | 
					
						
							|  |  |  | struct direntry; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-26 15:28:56 +00:00
										 |  |  | const char *BLI_getDefaultDocumentFolder(void); | 
					
						
							| 
									
										
										
										
											2010-07-04 15:35:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-16 14:40:46 +00:00
										 |  |  | char *BLI_get_folder(int folder_id, const char *subfolder); | 
					
						
							|  |  |  | char *BLI_get_folder_create(int folder_id, const char *subfolder); | 
					
						
							|  |  |  | char *BLI_get_user_folder_notest(int folder_id, const char *subfolder); | 
					
						
							| 
									
										
										
										
											2011-04-11 13:56:58 +00:00
										 |  |  | char *BLI_get_folder_version(const int id, const int ver, const int do_check); | 
					
						
							| 
									
										
										
										
											2010-07-04 15:35:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* folder_id */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-16 16:02:07 +00:00
										 |  |  | /* general, will find based on user/local/system priority */ | 
					
						
							| 
									
										
										
										
											2010-07-04 15:35:23 +00:00
										 |  |  | #define BLENDER_DATAFILES			2
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* user-specific */ | 
					
						
							|  |  |  | #define BLENDER_USER_CONFIG			31
 | 
					
						
							|  |  |  | #define BLENDER_USER_DATAFILES		32
 | 
					
						
							|  |  |  | #define BLENDER_USER_SCRIPTS		33
 | 
					
						
							|  |  |  | #define BLENDER_USER_PLUGINS		34
 | 
					
						
							| 
									
										
										
										
											2010-07-15 21:39:47 +00:00
										 |  |  | #define BLENDER_USER_AUTOSAVE		35
 | 
					
						
							| 
									
										
										
										
											2010-07-04 15:35:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* system */ | 
					
						
							|  |  |  | #define BLENDER_SYSTEM_DATAFILES	52
 | 
					
						
							|  |  |  | #define BLENDER_SYSTEM_SCRIPTS		53
 | 
					
						
							|  |  |  | #define BLENDER_SYSTEM_PLUGINS		54
 | 
					
						
							|  |  |  | #define BLENDER_SYSTEM_PYTHON		54
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-11 13:56:58 +00:00
										 |  |  | /* for BLI_get_folder_version only */ | 
					
						
							|  |  |  | #define BLENDER_RESOURCE_PATH_USER		0
 | 
					
						
							|  |  |  | #define BLENDER_RESOURCE_PATH_LOCAL		1
 | 
					
						
							|  |  |  | #define BLENDER_RESOURCE_PATH_SYSTEM	2
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-04 15:35:23 +00:00
										 |  |  | #define BLENDER_STARTUP_FILE	"startup.blend"
 | 
					
						
							|  |  |  | #define BLENDER_BOOKMARK_FILE	"bookmarks.txt"
 | 
					
						
							|  |  |  | #define BLENDER_HISTORY_FILE	"recent-files.txt"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-27 06:41:48 +00:00
										 |  |  | #ifdef WIN32
 | 
					
						
							|  |  |  | #define SEP '\\'
 | 
					
						
							|  |  |  | #define ALTSEP '/'
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define SEP '/'
 | 
					
						
							|  |  |  | #define ALTSEP '\\'
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-21 09:26:28 +00:00
										 |  |  | void BLI_setenv(const char *env, const char *val); | 
					
						
							| 
									
										
										
										
											2009-10-19 18:44:09 +00:00
										 |  |  | void BLI_setenv_if_new(const char *env, const char* val); | 
					
						
							| 
									
										
										
										
											2009-04-11 02:18:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | void BLI_make_file_string(const char *relabase, char *string,  const char *dir, const char *file); | 
					
						
							|  |  |  | void BLI_make_exist(char *dir); | 
					
						
							| 
									
										
										
										
											2010-11-16 14:40:46 +00:00
										 |  |  | void BLI_make_existing_file(const char *name); | 
					
						
							| 
									
										
										
										
											2011-10-15 03:56:05 +00:00
										 |  |  | void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen); | 
					
						
							| 
									
										
										
										
											2011-10-21 02:13:36 +00:00
										 |  |  | void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen); | 
					
						
							|  |  |  | void BLI_split_file_part(const char *string, char *file, const size_t filelen); | 
					
						
							| 
									
										
										
										
											2011-05-02 10:22:49 +00:00
										 |  |  | void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file); | 
					
						
							| 
									
										
										
										
											2010-06-05 21:19:59 +00:00
										 |  |  | char *BLI_path_basename(char *path); | 
					
						
							| 
									
										
										
										
											2011-05-02 10:22:49 +00:00
										 |  |  | 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); | 
					
						
							| 
									
										
										
										
											2010-10-27 06:41:48 +00:00
										 |  |  | char *BLI_last_slash(const char *string); | 
					
						
							|  |  |  | int	  BLI_add_slash(char *string); | 
					
						
							|  |  |  | void  BLI_del_slash(char *string); | 
					
						
							|  |  |  | char *BLI_first_slash(char *string); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-02 10:22:49 +00:00
										 |  |  | void BLI_getlastdir(const char* dir, char *last, const size_t maxlen); | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | int BLI_testextensie(const char *str, const char *ext); | 
					
						
							| 
									
										
										
										
											2010-08-03 12:34:42 +00:00
										 |  |  | int BLI_testextensie_array(const char *str, const char **ext_array); | 
					
						
							| 
									
										
										
										
											2010-09-24 06:20:43 +00:00
										 |  |  | int BLI_testextensie_glob(const char *str, const char *ext_fnmatch); | 
					
						
							| 
									
										
										
										
											2011-04-10 09:37:04 +00:00
										 |  |  | int BLI_replace_extension(char *path, size_t maxlen, const char *ext); | 
					
						
							| 
									
										
										
										
											2011-10-31 00:23:42 +00:00
										 |  |  | int BLI_ensure_extension(char *path, size_t maxlen, const char *ext); | 
					
						
							| 
									
										
										
										
											2009-11-29 19:16:52 +00:00
										 |  |  | void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len); | 
					
						
							| 
									
										
										
										
											2010-11-07 08:49:07 +00:00
										 |  |  | int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, const char defname[], char delim, char *name, short name_len); | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | void BLI_newname(char * name, int add); | 
					
						
							| 
									
										
										
										
											2010-04-23 23:01:50 +00:00
										 |  |  | 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); | 
					
						
							| 
									
										
										
										
											2010-11-07 08:49:07 +00:00
										 |  |  | int BLI_split_name_num(char *left, int *nr, const char *name, const char delim); | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | void BLI_splitdirstring(char *di,char *fi); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 12:43:53 +00:00
										 |  |  | /* make sure path separators conform to system one */ | 
					
						
							|  |  |  | void BLI_clean(char *path); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  | 	 * dir can be any input, like from buttons, and this function | 
					
						
							|  |  |  | 	 * converts it to a regular full path. | 
					
						
							|  |  |  | 	 * Also removes garbage from directory paths, like /../ or double slashes etc  | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2011-03-11 00:30:51 +00:00
										 |  |  | void BLI_cleanup_file(const char *relabase, char *dir); /* removes trailing slash */ | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */ | 
					
						
							| 
									
										
										
										
											2011-03-11 00:30:51 +00:00
										 |  |  | void BLI_cleanup_path(const char *relabase, char *dir); /* doesn't touch trailing slash */ | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* go back one directory */ | 
					
						
							|  |  |  | int BLI_parent_dir(char *path); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-10 19:19:54 +00:00
										 |  |  | /* return whether directory is root and thus has no parent dir */ | 
					
						
							|  |  |  | int BLI_has_parent(char *path); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * Blender's path code replacement function. | 
					
						
							|  |  |  | 	 * Bases @a path strings leading with "//" by the | 
					
						
							|  |  |  | 	 * directory @a basepath, and replaces instances of | 
					
						
							|  |  |  | 	 * '#' with the @a framenum. Results are written | 
					
						
							|  |  |  | 	 * back into @a path. | 
					
						
							|  |  |  | 	 *  | 
					
						
							|  |  |  | 	 * @a path The path to convert | 
					
						
							|  |  |  | 	 * @a basepath The directory to base relative paths with. | 
					
						
							|  |  |  | 	 * @a framenum The framenumber to replace the frame code with. | 
					
						
							|  |  |  | 	 * @retval Returns true if the path was relative (started with "//"). | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-03-09 17:36:23 +00:00
										 |  |  | 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_path_rel(char *file, const char *relfile); | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-06 06:03:48 +00:00
										 |  |  | #ifdef WIN32
 | 
					
						
							|  |  |  | #  define BLI_path_cmp BLI_strcasecmp
 | 
					
						
							|  |  |  | #  define BLI_path_ncmp BLI_strncasecmp
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #  define BLI_path_cmp strcmp
 | 
					
						
							|  |  |  | #  define BLI_path_ncmp strncmp
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * Change every @a from in @a string into @a to. The | 
					
						
							|  |  |  | 	 * result will be in @a string | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @a string The string to work on | 
					
						
							|  |  |  | 	 * @a from The character to replace | 
					
						
							|  |  |  | 	 * @a to The character to replace with | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | void BLI_char_switch(char *string, char from, char to); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-21 17:37:38 +00:00
										 |  |  | 	/* Initialize path to program executable */ | 
					
						
							|  |  |  | void BLI_init_program_path(const char *argv0); | 
					
						
							|  |  |  | 	/* Initialize path to temporary directory.
 | 
					
						
							|  |  |  | 	 * NOTE: On Window userdir will be set to the temporary directory! */ | 
					
						
							|  |  |  | void BLI_init_temporary_dir(char *userdir); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Path to executable */ | 
					
						
							|  |  |  | const char *BLI_program_path(void); | 
					
						
							|  |  |  | 	/* Path to directory of executable */ | 
					
						
							|  |  |  | const char *BLI_program_dir(void); | 
					
						
							|  |  |  | 	/* Path to temporary directory (with trailing slash) */ | 
					
						
							|  |  |  | const char *BLI_temporary_dir(void); | 
					
						
							|  |  |  | 	/* Path to the system temporary directory (with trailing slash) */ | 
					
						
							|  |  |  | void BLI_system_temporary_dir(char *dir); | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef WITH_ICONV
 | 
					
						
							|  |  |  | void BLI_string_to_utf8(char *original, char *utf_8, const char *code); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-04 16:20:42 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 |