/* Some font have additional file with metrics information, * in general, the extension of the file is: .afm or .pfm */ char *blf_dir_metrics_search(const char *filename) { char *mfile; char *s; mfile= BLI_strdup(filename); s= strrchr(mfile, '.'); if (s) { if (BLI_strnlen(s, 4) < 4) { MEM_freeN(mfile); return NULL; } s++; s[0]= 'a'; s[1]= 'f'; s[2]= 'm'; /* first check .afm */ if (BLI_exist(s)) return s; /* and now check .pfm */ s[0]= 'p'; if (BLI_exist(s)) return s; } MEM_freeN(mfile); return NULL; }
/* removes a slash if there is one */ void BLI_del_slash(char *string) { int len = strlen(string); while (len) { #ifdef WIN32 if (string[len-1]=='\\') { #else if (string[len-1]=='/') { #endif string[len-1] = '\0'; len--; } else { break; } } } static int add_win32_extension(char *name) { int retval = 0; int type; type = BLI_exist(name); if ((type == 0) || S_ISDIR(type)) { #ifdef _WIN32 char filename[FILE_MAXDIR+FILE_MAXFILE]; char ext[FILE_MAXDIR+FILE_MAXFILE]; const char *extensions = getenv("PATHEXT"); if (extensions) { char *temp; do { strcpy(filename, name); temp = strstr(extensions, ";"); if (temp) { strncpy(ext, extensions, temp - extensions); ext[temp - extensions] = 0; extensions = temp + 1; strcat(filename, ext); } else { strcat(filename, extensions); } type = BLI_exist(filename); if (type && (! S_ISDIR(type))) { retval = 1; strcpy(name, filename); break; } } while (temp); } #endif } else { retval = 1; } return (retval); }
char *blf_dir_search(const char *file) { DirBLF *dir; char full_path[FILE_MAXDIR+FILE_MAXFILE]; char *s= NULL; 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)) { s= BLI_strdup(full_path); break; } } if (!s) { /* check the current directory, why not ? */ if (BLI_exist(file)) s= BLI_strdup(file); } return s; }
static int fluidsim_find_lastframe(FluidsimSettings *fss) { char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; int curFrame = 1; BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath); BLI_path_abs(targetDir, G.main->name); do { BLI_strncpy(targetFile, targetDir, sizeof(targetFile)); BLI_path_frame(targetFile, curFrame++, 0); } while(BLI_exist(targetFile)); return curFrame - 1; }
int collada_export(Scene *sce, const char *filepath, int selected) { DocumentExporter exp; /* annoying, collada crashes if file cant be created! [#27162] */ if(!BLI_exist(filepath)) { BLI_make_existing_file(filepath); /* makes the dir if its not there */ if(BLI_touch(filepath) == 0) { return 0; } } /* end! */ exp.exportCurrentScene(sce, filepath, selected); return 1; }
/* 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)); }
int BLI_exists(char *file) { return BLI_exist(file); }