Code cleanup: remove BLI_exist, now there is only BLI_exists. One function just

called the other, they did the same thing.
This commit is contained in:
Brecht Van Lommel 2011-10-21 22:33:41 +00:00
parent 932aa116df
commit 88473fd49a
14 changed files with 44 additions and 71 deletions

@ -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);

@ -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;

@ -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

@ -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 '/'

@ -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 <stddef.h>
#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 */

@ -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];

@ -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);

@ -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)

@ -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;

@ -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);

@ -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);

@ -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);
}
}

@ -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;
}

@ -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);
}
}