From 88473fd49a4f5330f8f6a932b0c9eccf28aaa459 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 21 Oct 2011 22:33:41 +0000 Subject: Code cleanup: remove BLI_exist, now there is only BLI_exists. One function just called the other, they did the same thing. --- source/blender/blenfont/intern/blf_dir.c | 8 ++--- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenlib/BLI_fileops.h | 9 ------ source/blender/blenlib/BLI_path_util.h | 15 ---------- source/blender/blenlib/BLI_storage.h | 41 ++++++++++---------------- source/blender/blenlib/intern/fileops.c | 4 --- source/blender/blenlib/intern/path_util.c | 16 ++++++++-- source/blender/blenlib/intern/storage.c | 4 +-- source/blender/collada/collada.cpp | 2 +- source/blender/editors/physics/physics_fluid.c | 2 +- source/blender/editors/space_file/file_ops.c | 2 +- source/blender/editors/space_file/fsmenu.c | 2 +- source/blender/makesrna/intern/rna_fluidsim.c | 2 +- source/blender/render/intern/source/pipeline.c | 6 ++-- 14 files changed, 44 insertions(+), 71 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 46be49b37e9..3fe66118cda 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -136,7 +136,7 @@ char *blf_dir_search(const char *file) for(dir=global_font_dir.first; dir; dir= dir->next) { BLI_join_dirfile(full_path, sizeof(full_path), dir->path, file); - if (BLI_exist(full_path)) { + if (BLI_exists(full_path)) { s= BLI_strdup(full_path); break; } @@ -144,7 +144,7 @@ char *blf_dir_search(const char *file) if (!s) { /* check the current directory, why not ? */ - if (BLI_exist(file)) + if (BLI_exists(file)) s= BLI_strdup(file); } @@ -198,13 +198,13 @@ char *blf_dir_metrics_search(const char *filename) s[2]= 'm'; /* first check .afm */ - if (BLI_exist(s)) + if (BLI_exists(s)) return s; /* and now check .pfm */ s[0]= 'p'; - if (BLI_exist(s)) + if (BLI_exists(s)) return s; } MEM_freeN(mfile); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index f12e9698810..d4753f30ef2 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2363,7 +2363,7 @@ void BKE_ptcache_remove(void) ptcache_path(NULL, path); - if (BLI_exist(path)) { + if (BLI_exists(path)) { /* The pointcache dir exists? - remove all pointcache */ DIR *dir; diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index 21d28ca3185..354931e306a 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -46,10 +46,6 @@ void BLI_recurdir_fileops(const char *dirname); int BLI_link(const char *file, const char *to); int BLI_is_writable(const char *filename); -/** - * @attention Do not confuse with BLI_exist - */ -int BLI_exists(const char *file); int BLI_copy_fileops(const char *file, const char *to); int BLI_rename(const char *from, const char *to); int BLI_gzip(const char *from, const char *to); @@ -58,11 +54,6 @@ int BLI_delete(const char *file, int dir, int recursive); int BLI_move(const char *file, const char *to); int BLI_touch(const char *file); -/* only for the sane unix world: direct calls to system functions :( */ -#ifndef WIN32 -void BLI_setCmdCallBack(int (*f)(char*)); -#endif - #ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 56ecec042f2..82794e08fa0 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -65,10 +65,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check); #define BLENDER_SYSTEM_PLUGINS 54 #define BLENDER_SYSTEM_PYTHON 54 -#define BLENDER_TEMP 80 - -#define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS) - /* for BLI_get_folder_version only */ #define BLENDER_RESOURCE_PATH_USER 0 #define BLENDER_RESOURCE_PATH_LOCAL 1 @@ -78,17 +74,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check); #define BLENDER_BOOKMARK_FILE "bookmarks.txt" #define BLENDER_HISTORY_FILE "recent-files.txt" -#ifdef WIN32 -#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s" -#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s" -#elif defined(__APPLE__) -#define BLENDER_USER_FORMAT "%s/Blender/%s" -#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s" -#else -#define BLENDER_USER_FORMAT "%s/.blender/%s" -#define BLENDER_SYSTEM_FORMAT "%s/blender/%s" -#endif - #ifdef WIN32 #define SEP '\\' #define ALTSEP '/' diff --git a/source/blender/blenlib/BLI_storage.h b/source/blender/blenlib/BLI_storage.h index 017f9877baf..13c78b711a8 100644 --- a/source/blender/blenlib/BLI_storage.h +++ b/source/blender/blenlib/BLI_storage.h @@ -33,46 +33,35 @@ * \ingroup bli */ -#ifdef WIN32 -/* for size_t, only needed on win32 for some reason */ +/* for size_t (needed on windows) */ #include -#endif struct direntry; - -void BLI_adddirstrings(void); -void BLI_builddir(const char *dirname, const char *relname); -int BLI_compare(struct direntry *entry1, struct direntry *entry2); - size_t BLI_filesize(int file); size_t BLI_filepathsize(const char *path); double BLI_diskfree(const char *dir); char *BLI_getwdN(char *dir, const int maxncpy); unsigned int BLI_getdir(const char *dirname, struct direntry **filelist); -/** - * @attention Do not confuse with BLI_exists - */ -int BLI_exist(const char *name); -/** - * Read a file as ASCII lines. An empty list is - * returned if the file cannot be opened or read. - * - * @attention The returned list should be free'd with - * BLI_free_file_lines. - * - * @param name The name of the file to read. - * @retval A list of strings representing the file lines. - */ + /* test if file or directory exists */ +int BLI_exists(const char *name); + /* test if there is a directory at the specified path */ int BLI_is_dir(const char *file); -struct LinkNode *BLI_read_file_as_lines(const char *name); +/** + * Read a file as ASCII lines. An empty list is + * returned if the file cannot be opened or read. + * + * @attention The returned list should be free'd with + * BLI_free_file_lines. + * + * @param name The name of the file to read. + * @retval A list of strings representing the file lines. + */ - /** - * Free the list returned by BLI_read_file_as_lines. - */ +struct LinkNode *BLI_read_file_as_lines(const char *name); void BLI_free_file_lines(struct LinkNode *lines); /* Compare if one was last modified before the other */ diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index e848ad8d0d3..3a2efbd6feb 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -195,10 +195,6 @@ int BLI_touch(const char *file) return 0; } -int BLI_exists(const char *file) { - return BLI_exist(file); -} - #ifdef WIN32 static char str[MAXPATHLEN+12]; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index f57ac09c9b9..91e813a0350 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -84,6 +84,18 @@ #endif /* WIN32 */ +/* standard paths */ +#ifdef WIN32 +#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s" +#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s" +#elif defined(__APPLE__) +#define BLENDER_USER_FORMAT "%s/Blender/%s" +#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s" +#else +#define BLENDER_USER_FORMAT "%s/.blender/%s" +#define BLENDER_SYSTEM_FORMAT "%s/blender/%s" +#endif + /* local */ #define UNIQUE_NAME_MAX 128 @@ -1635,7 +1647,7 @@ static int add_win32_extension(char *name) int retval = 0; int type; - type = BLI_exist(name); + type = BLI_exists(name); if ((type == 0) || S_ISDIR(type)) { #ifdef _WIN32 char filename[FILE_MAXDIR+FILE_MAXFILE]; @@ -1655,7 +1667,7 @@ static int add_win32_extension(char *name) strcat(filename, extensions); } - type = BLI_exist(filename); + type = BLI_exists(filename); if (type && (! S_ISDIR(type))) { retval = 1; strcpy(name, filename); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 7638e95b4ec..8b383f5fd11 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -438,7 +438,7 @@ size_t BLI_filepathsize(const char *path) } -int BLI_exist(const char *name) +int BLI_exists(const char *name) { #if defined(WIN32) && !defined(__MINGW32__) struct _stat64i32 st; @@ -471,7 +471,7 @@ int BLI_exist(const char *name) /* would be better in fileops.c except that it needs stat.h so add here */ int BLI_is_dir(const char *file) { - return S_ISDIR(BLI_exist(file)); + return S_ISDIR(BLI_exists(file)); } LinkNode *BLI_read_file_as_lines(const char *name) diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index 8059b1cf3ff..b411d61fe37 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -60,7 +60,7 @@ extern "C" export_settings.filepath = (char *)filepath; /* annoying, collada crashes if file cant be created! [#27162] */ - if(!BLI_exist(filepath)) { + if(!BLI_exists(filepath)) { BLI_make_existing_file(filepath); /* makes the dir if its not there */ if(BLI_touch(filepath) == 0) { return 0; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 918adcac138..c6ba7118925 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -833,7 +833,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss) curFrame++; - if((exists = BLI_exist(targetFile))) + if((exists = BLI_exists(targetFile))) { BLI_delete(targetFile, 0, 0); BLI_delete(targetFileVel, 0, 0); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 559873bd601..7a379b93ee6 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -749,7 +749,7 @@ int file_exec(bContext *C, wmOperator *exec_op) file_sfile_to_operator(op, sfile, filepath); - if (BLI_exist(sfile->params->dir)) + if (BLI_exists(sfile->params->dir)) fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, 0, 1); BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index bd9a38ab27e..a843129c4d9 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -278,7 +278,7 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename) if (line[len-1] == '\n') { line[len-1] = '\0'; } - if (BLI_exist(line)) { + if (BLI_exists(line)) { fsmenu_insert_entry(fsmenu, category, line, 0, 1); } } diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index c114c44ad77..13e9c88bfe3 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -96,7 +96,7 @@ static int fluidsim_find_lastframe(FluidsimSettings *fss) do { BLI_strncpy(targetFile, targetDir, sizeof(targetFile)); BLI_path_frame(targetFile, curFrame++, 0); - } while(BLI_exist(targetFile)); + } while(BLI_exists(targetFile)); return curFrame - 1; } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 405779c360f..104a298acf1 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -3146,11 +3146,11 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri if(scene->r.mode & (R_NO_OVERWRITE | R_TOUCH)) BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE); - if(scene->r.mode & R_NO_OVERWRITE && BLI_exist(name)) { + if(scene->r.mode & R_NO_OVERWRITE && BLI_exists(name)) { printf("skipping existing frame \"%s\"\n", name); continue; } - if(scene->r.mode & R_TOUCH && !BLI_exist(name)) { + if(scene->r.mode & R_TOUCH && !BLI_exists(name)) { BLI_make_existing_file(name); /* makes the dir if its not there */ BLI_touch(name); } @@ -3175,7 +3175,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri if(G.afbreek==1) { /* remove touched file */ if(BKE_imtype_is_movie(scene->r.imtype) == 0) { - if (scene->r.mode & R_TOUCH && BLI_exist(name) && BLI_filepathsize(name) == 0) { + if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_filepathsize(name) == 0) { BLI_delete(name, 0, 0); } } -- cgit v1.2.3