/* copied from rna_fluidsim.c: fluidsim_find_lastframe() */ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *relbase) { char targetDir[FILE_MAX], targetFile[FILE_MAX]; char targetDirVel[FILE_MAX], targetFileVel[FILE_MAX]; char previewDir[FILE_MAX], previewFile[FILE_MAX]; int curFrame = 1, exists = 0; BLI_join_dirfile(targetDir, sizeof(targetDir), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME); BLI_join_dirfile(targetDirVel, sizeof(targetDirVel), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_VEL_FNAME); BLI_join_dirfile(previewDir, sizeof(previewDir), fss->surfdataPath, OB_FLUIDSIM_SURF_PREVIEW_OBJ_FNAME); BLI_path_abs(targetDir, relbase); BLI_path_abs(targetDirVel, relbase); BLI_path_abs(previewDir, relbase); do { BLI_strncpy(targetFile, targetDir, sizeof(targetFile)); BLI_strncpy(targetFileVel, targetDirVel, sizeof(targetFileVel)); BLI_strncpy(previewFile, previewDir, sizeof(previewFile)); BLI_path_frame(targetFile, curFrame, 0); BLI_path_frame(targetFileVel, curFrame, 0); BLI_path_frame(previewFile, curFrame, 0); curFrame++; if ((exists = BLI_exists(targetFile))) { BLI_delete(targetFile, false, false); BLI_delete(targetFileVel, false, false); BLI_delete(previewFile, false, false); } } while (exists); return; }
static void get_index_dir(struct anim * anim, char * index_dir) { if (!anim->index_dir[0]) { char fname[FILE_MAXFILE]; BLI_strncpy(index_dir, anim->name, FILE_MAXDIR); BLI_splitdirstring(index_dir, fname); BLI_join_dirfile(index_dir, FILE_MAXDIR, index_dir, "BL_proxy"); BLI_join_dirfile(index_dir, FILE_MAXDIR, index_dir, fname); } else { BLI_strncpy(index_dir, anim->index_dir, FILE_MAXDIR); } }
static void file_expand_directory(bContext *C) { SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { if ( sfile->params->dir[0] == '~' ) { char tmpstr[sizeof(sfile->params->dir)-1]; BLI_strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr)); BLI_join_dirfile(sfile->params->dir, sizeof(sfile->params->dir), BLI_getDefaultDocumentFolder(), tmpstr); } #ifdef WIN32 if (sfile->params->dir[0] == '\0') { get_default_root(sfile->params->dir); } /* change "C:" --> "C:\", [#28102] */ else if ( (isalpha(sfile->params->dir[0]) && (sfile->params->dir[1] == ':')) && (sfile->params->dir[2] == '\0') ) { sfile->params->dir[2]= '\\'; sfile->params->dir[3]= '\0'; } #endif } }
/** * Constructs in \a targetpath the name of a directory relative to a version-specific * subdirectory in the parent directory of the Blender executable. * * \param targetpath String to return path * \param folder_name Optional folder name within version-specific directory * \param subfolder_name Optional subfolder name within folder_name * \param ver To construct name of version-specific directory within bprogdir * \return true if such a directory exists. */ static bool get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name, const int ver) { char relfolder[FILE_MAX]; #ifdef PATH_DEBUG printf("%s...\n", __func__); #endif if (folder_name) { if (subfolder_name) { BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name); } else { BLI_strncpy(relfolder, folder_name, sizeof(relfolder)); } } else { relfolder[0] = '\0'; } /* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */ #ifdef __APPLE__ static char osx_resourses[FILE_MAX]; /* due new codesign situation in OSX > 10.9.5 we must move the blender_version dir with contents to Resources */ sprintf(osx_resourses, "%s../Resources", bprogdir); return test_path(targetpath, osx_resourses, blender_version_decimal(ver), relfolder); #else return test_path(targetpath, bprogdir, blender_version_decimal(ver), relfolder); #endif }
/** * Concatenates path_base, (optional) path_sep and (optional) folder_name into targetpath, * returning true if result points to a directory. */ static bool test_path(char *targetpath, const char *path_base, const char *path_sep, const char *folder_name) { char tmppath[FILE_MAX]; if (path_sep) BLI_join_dirfile(tmppath, sizeof(tmppath), path_base, path_sep); else BLI_strncpy(tmppath, path_base, sizeof(tmppath)); /* rare cases folder_name is omitted (when looking for ~/.blender/2.xx dir only) */ if (folder_name) BLI_make_file_string("/", targetpath, tmppath, folder_name); else BLI_strncpy(targetpath, tmppath, sizeof(tmppath)); /* FIXME: why is "//" on front of tmppath expanded to "/" (by BLI_join_dirfile) * if folder_name is specified but not otherwise? */ if (BLI_is_dir(targetpath)) { #ifdef PATH_DEBUG printf("\t%s found: %s\n", __func__, targetpath); #endif return true; } else { #ifdef PATH_DEBUG printf("\t%s missing: %s\n", __func__, targetpath); #endif //targetpath[0] = '\0'; return false; } }
static void file_expand_directory(bContext *C) { SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { /* TODO, what about // when relbase isn't valid? */ if (G.relbase_valid && BLI_path_is_rel(sfile->params->dir)) { BLI_path_abs(sfile->params->dir, G.main->name); } else if (sfile->params->dir[0] == '~') { char tmpstr[sizeof(sfile->params->dir) - 1]; BLI_strncpy(tmpstr, sfile->params->dir + 1, sizeof(tmpstr)); BLI_join_dirfile(sfile->params->dir, sizeof(sfile->params->dir), BLI_getDefaultDocumentFolder(), tmpstr); } else if (sfile->params->dir[0] == '\0') #ifndef WIN32 { sfile->params->dir[0] = '/'; sfile->params->dir[1] = '\0'; } #else { get_default_root(sfile->params->dir); } /* change "C:" --> "C:\", [#28102] */ else if ((isalpha(sfile->params->dir[0]) && (sfile->params->dir[1] == ':')) && (sfile->params->dir[2] == '\0')) { sfile->params->dir[2] = '\\'; sfile->params->dir[3] = '\0'; } #endif }
static char *check_destination(const char *file, const char *to) { struct stat st; if (!stat(to, &st)) { if (S_ISDIR(st.st_mode)) { char *str, *path; const char *filename; size_t len = 0; str = strip_last_slash(file); filename = BLI_last_slash(str); if (!filename) { MEM_freeN(str); return (char *)to; } /* skip slash */ filename += 1; len = strlen(to) + strlen(filename) + 1; path = MEM_callocN(len + 1, "check_destination path"); BLI_join_dirfile(path, len + 1, to, filename); MEM_freeN(str); return path; } } return (char *)to; }
static int test_path(char *targetpath, const char *path_base, const char *path_sep, const char *folder_name) { char tmppath[FILE_MAX]; if (path_sep) BLI_join_dirfile(tmppath, sizeof(tmppath), path_base, path_sep); else BLI_strncpy(tmppath, path_base, sizeof(tmppath)); /* rare cases folder_name is omitted (when looking for ~/.blender/2.xx dir only) */ if (folder_name) BLI_make_file_string("/", targetpath, tmppath, folder_name); else BLI_strncpy(targetpath, tmppath, sizeof(tmppath)); if (BLI_is_dir(targetpath)) { #ifdef PATH_DEBUG2 printf("\tpath found: %s\n", targetpath); #endif return 1; } else { #ifdef PATH_DEBUG2 printf("\tpath missing: %s\n", targetpath); #endif //targetpath[0] = '\0'; return 0; } }
static void get_proxy_filename(struct anim *anim, IMB_Proxy_Size preview_size, char *fname, int temp) { char index_dir[FILE_MAXDIR]; int i = IMB_proxy_size_to_array_index(preview_size); char proxy_name[256]; char proxy_temp_name[256]; char stream_suffix[20]; stream_suffix[0] = 0; if (anim->streamindex > 0) { BLI_snprintf(stream_suffix, sizeof(stream_suffix), "_st%d", anim->streamindex); } BLI_snprintf(proxy_name, sizeof(proxy_name), "proxy_%d%s.avi", (int) (proxy_fac[i] * 100), stream_suffix); BLI_snprintf(proxy_temp_name, sizeof(proxy_temp_name), "proxy_%d%s_part.avi", (int) (proxy_fac[i] * 100), stream_suffix); get_index_dir(anim, index_dir, sizeof(index_dir)); BLI_join_dirfile(fname, FILE_MAXFILE + FILE_MAXDIR, index_dir, temp ? proxy_temp_name : proxy_name); }
/** * Dump GLSL shaders to disk * * This is used for profiling shader performance externally and debug if shader code is correct. * If called with no code, it simply bumps the shader index, so different shaders for the same * program share the same index. */ static void gpu_dump_shaders(const char **code, const int num_shaders, const char *extension) { if ((G.debug & G_DEBUG_GPU_SHADERS) == 0) { return; } /* We use the same shader index for shaders in the same program. * So we call this function once before calling for the individual shaders. */ static int shader_index = 0; if (code == NULL) { shader_index++; BLI_assert(STREQ(DEBUG_SHADER_NONE, extension)); return; } /* Determine the full path of the new shader. */ char shader_path[FILE_MAX]; char file_name[512] = {'\0'}; sprintf(file_name, "%04d.%s", shader_index, extension); BLI_join_dirfile(shader_path, sizeof(shader_path), BKE_tempdir_session(), file_name); /* Write shader to disk. */ FILE *f = fopen(shader_path, "w"); if (f == NULL) { printf("Error writing to file: %s\n", shader_path); } for (int j = 0; j < num_shaders; j++) { fprintf(f, "%s", code[j]); } fclose(f); printf("Shader file written to disk: %s\n", shader_path); }
static void filelist_read_library(struct FileList* filelist) { if (!filelist) return; BLI_cleanup_dir(G.main->name, filelist->dir); filelist_from_library(filelist); if (!filelist->libfiledata) { int num; struct direntry *file; BLI_make_exist(filelist->dir); filelist_read_dir(filelist); file = filelist->filelist; for (num=0; num<filelist->numfiles; num++, file++) { if (BLO_has_bfile_extension(file->relname)) { char name[FILE_MAX]; BLI_join_dirfile(name, sizeof(name), filelist->dir, file->relname); /* prevent current file being used as acceptable dir */ if (BLI_path_cmp(G.main->name, name) != 0) { file->type &= ~S_IFMT; file->type |= S_IFDIR; } } } } }
/** When this method is called, the writer must write the image. * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) { if (mImportStage != General) return true; const std::string& imagepath = image->getImageURI().toNativePath(); char dir[FILE_MAX]; char absolute_path[FILE_MAX]; const char *workpath; BLI_split_dir_part(this->import_settings->filepath, dir, sizeof(dir)); BLI_join_dirfile(absolute_path, sizeof(absolute_path), dir, imagepath.c_str()); if (BLI_exists(absolute_path)) { workpath = absolute_path; } else { // Maybe imagepath was already absolute ? if (!BLI_exists(imagepath.c_str())) { fprintf(stderr, "Image not found: %s.\n", imagepath.c_str() ); return true; } workpath = imagepath.c_str(); } Image *ima = BKE_image_load_exists(workpath); if (!ima) { fprintf(stderr, "Cannot create image: %s\n", workpath); return true; } this->uid_image_map[image->getUniqueId()] = ima; return true; }
void autocomplete_directory(struct bContext *C, char *str, void *arg_v) { char tmp[FILE_MAX]; SpaceFile *sfile= CTX_wm_space_file(C); /* search if str matches the beginning of name */ if(str[0] && sfile->files) { AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); int nentries = filelist_numfiles(sfile->files); int i; for(i= 0; i<nentries; ++i) { struct direntry* file = filelist_file(sfile->files, i); const char* dir = filelist_dir(sfile->files); if (file && S_ISDIR(file->type)) { // BLI_make_file_string(G.sce, tmp, dir, file->relname); BLI_join_dirfile(tmp, dir, file->relname); autocomplete_do_name(autocpl,tmp); } } autocomplete_end(autocpl, str); if (BLI_exists(str)) { BLI_add_slash(str); } else { BLI_make_exist(str); } } }
static void get_tc_filename(struct anim *anim, IMB_Timecode_Type tc, char *fname) { char index_dir[FILE_MAXDIR]; int i = IMB_timecode_to_array_index(tc); const char *index_names[] = { "record_run%s.blen_tc", "free_run%s.blen_tc", "interp_free_run%s.blen_tc", "record_run_no_gaps%s.blen_tc" }; char stream_suffix[20]; char index_name[256]; stream_suffix[0] = 0; if (anim->streamindex > 0) { BLI_snprintf(stream_suffix, 20, "_st%d", anim->streamindex); } BLI_snprintf(index_name, 256, index_names[i], stream_suffix); get_index_dir(anim, index_dir, sizeof(index_dir)); BLI_join_dirfile(fname, FILE_MAXFILE + FILE_MAXDIR, index_dir, index_name); }
static int get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name, const int ver) { char relfolder[FILE_MAX]; #ifdef PATH_DEBUG2 printf("get_path_local...\n"); #endif if (folder_name) { if (subfolder_name) { BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name); } else { BLI_strncpy(relfolder, folder_name, sizeof(relfolder)); } } else { relfolder[0] = '\0'; } /* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */ if (test_path(targetpath, bprogdir, blender_version_decimal(ver), relfolder)) return 1; return 0; }
/** * EditTranslation utility funcs and operator, * \note: this includes utility functions and button matching checks. * this only works in conjunction with a py operator! */ static void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen) { char tstr[32]; /* Should be more than enough! */ /* First, full lang code. */ BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng); BLI_join_dirfile(path, maxlen, root, uilng); BLI_path_append(path, maxlen, tstr); if (BLI_is_file(path)) { return; } /* Now try without the second iso code part (_ES in es_ES). */ { const char *tc = NULL; size_t szt = 0; tstr[0] = '\0'; tc = strchr(uilng, '_'); if (tc) { szt = tc - uilng; if (szt < sizeof(tstr)) { /* Paranoid, should always be true! */ BLI_strncpy(tstr, uilng, szt + 1); /* +1 for '\0' char! */ } } if (tstr[0]) { /* Because of some codes like sr_SR@latin... */ tc = strchr(uilng, '@'); if (tc) { BLI_strncpy(tstr + szt, tc, sizeof(tstr) - szt); } BLI_join_dirfile(path, maxlen, root, tstr); strcat(tstr, ".po"); BLI_path_append(path, maxlen, tstr); if (BLI_is_file(path)) { return; } } } /* Else no po file! */ path[0] = '\0'; }
/* initializes the path with either */ void modifier_path_init(char *path, int path_maxlen, const char *name) { /* elubie: changed this to default to the same dir as the render output * to prevent saving to C:\ on Windows */ BLI_join_dirfile(path, path_maxlen, G.relbase_valid ? "//" : BLI_temporary_dir(), name); }
/* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created. * The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name. */ static int new_folder_path(const char *parent, char *folder, char *name) { int i = 1; int len = 0; BLI_strncpy(name, "New Folder", FILE_MAXFILE); BLI_join_dirfile(folder, FILE_MAX, parent, name); /* XXX, not real length */ /* check whether folder with the name already exists, in this case * add number to the name. Check length of generated name to avoid * crazy case of huge number of folders each named 'New Folder (x)' */ while (BLI_exists(folder) && (len < FILE_MAXFILE)) { len = BLI_snprintf(name, FILE_MAXFILE, "New Folder(%d)", i); BLI_join_dirfile(folder, FILE_MAX, parent, name); /* XXX, not real length */ i++; } return (len < FILE_MAXFILE); }
//-------------------MODULE INITIALIZATION-------------------------------- PyObject *Freestyle_Init(void) { PyObject *module; // initialize modules module = PyModule_Create(&module_definition); if (!module) return NULL; PyDict_SetItemString(PySys_GetObject("modules"), module_definition.m_name, module); // update 'sys.path' for Freestyle Python API modules const char * const path = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "freestyle"); if (path) { char modpath[FILE_MAX]; BLI_join_dirfile(modpath, sizeof(modpath), path, "modules"); PyObject *sys_path = PySys_GetObject("path"); /* borrow */ PyObject *py_modpath = PyUnicode_FromString(modpath); PyList_Append(sys_path, py_modpath); Py_DECREF(py_modpath); #if 0 printf("Adding Python path: %s\n", modpath); #endif } else { printf("Freestyle: couldn't find 'scripts/freestyle/modules', Freestyle won't work properly.\n"); } // attach its classes (adding the object types to the module) // those classes have to be initialized before the others MediumType_Init(module); Nature_Init(module); BBox_Init(module); BinaryPredicate0D_Init(module); BinaryPredicate1D_Init(module); ContextFunctions_Init(module); FrsMaterial_Init(module); FrsNoise_Init(module); Id_Init(module); IntegrationType_Init(module); Interface0D_Init(module); Interface1D_Init(module); Iterator_Init(module); Operators_Init(module); SShape_Init(module); StrokeAttribute_Init(module); StrokeShader_Init(module); UnaryFunction0D_Init(module); UnaryFunction1D_Init(module); UnaryPredicate0D_Init(module); UnaryPredicate1D_Init(module); ViewMap_Init(module); ViewShape_Init(module); return module; }
void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) { BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */ if(RNA_struct_find_property(op->ptr, "relative_path")) { if(RNA_boolean_get(op->ptr, "relative_path")) { BLI_path_rel(filepath, G.main->name); } } if(RNA_struct_find_property(op->ptr, "filename")) { RNA_string_set(op->ptr, "filename", sfile->params->file); } if(RNA_struct_find_property(op->ptr, "directory")) { RNA_string_set(op->ptr, "directory", sfile->params->dir); } if(RNA_struct_find_property(op->ptr, "filepath")) { RNA_string_set(op->ptr, "filepath", filepath); } /* some ops have multiple files to select */ /* this is called on operators check() so clear collections first since * they may be already set. */ { PointerRNA itemptr; PropertyRNA *prop_files= RNA_struct_find_property(op->ptr, "files"); PropertyRNA *prop_dirs= RNA_struct_find_property(op->ptr, "dirs"); int i, numfiles = filelist_numfiles(sfile->files); if(prop_files) { RNA_property_collection_clear(op->ptr, prop_files); for (i=0; i<numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_FILES)) { struct direntry *file= filelist_file(sfile->files, i); RNA_property_collection_add(op->ptr, prop_files, &itemptr); RNA_string_set(&itemptr, "name", file->relname); } } } if(prop_dirs) { RNA_property_collection_clear(op->ptr, prop_dirs); for (i=0; i<numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) { struct direntry *file= filelist_file(sfile->files, i); RNA_property_collection_add(op->ptr, prop_dirs, &itemptr); RNA_string_set(&itemptr, "name", file->relname); } } } } }
static WorkspaceConfigFileData *workspace_config_file_read(const char *app_template) { const char *cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, app_template); char startup_file_path[FILE_MAX] = {0}; if (cfgdir) { BLI_join_dirfile(startup_file_path, sizeof(startup_file_path), cfgdir, BLENDER_STARTUP_FILE); } bool has_path = BLI_exists(startup_file_path); return (has_path) ? BKE_blendfile_workspace_config_read(startup_file_path, NULL, 0, NULL) : NULL; }
int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) { SpaceFile *sfile = CTX_wm_space_file(C); int match = AUTOCOMPLETE_NO_MATCH; /* search if str matches the beginning of name */ if (str[0] && sfile->files) { char dirname[FILE_MAX]; DIR *dir; struct dirent *de; BLI_split_dir_part(str, dirname, sizeof(dirname)); dir = opendir(dirname); if (dir) { AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); while ((de = readdir(dir)) != NULL) { if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0) { /* pass */ } else { char path[FILE_MAX]; BLI_stat_t status; BLI_join_dirfile(path, sizeof(path), dirname, de->d_name); if (BLI_stat(path, &status) == 0) { if (S_ISDIR(status.st_mode)) { /* is subdir */ autocomplete_do_name(autocpl, path); } } } } closedir(dir); match = autocomplete_end(autocpl, str); if (match) { if (match == AUTOCOMPLETE_FULL_MATCH) { BLI_add_slash(str); } else { BLI_strncpy(sfile->params->dir, str, sizeof(sfile->params->dir)); } } } } return match; }
/* appending of filename to dir (ensures for buffer size before appending) */ static void join_dirfile_alloc(char **dst, size_t *alloc_len, const char *dir, const char *file) { size_t len = strlen(dir) + strlen(file) + 1; if (*dst == NULL) *dst = MEM_mallocN(len + 1, "join_dirfile_alloc path"); else if (*alloc_len < len) *dst = MEM_reallocN(*dst, len + 1); *alloc_len = len; BLI_join_dirfile(*dst, len + 1, dir, file); }
bool file_draw_check_exists(SpaceFile *sfile) { if (sfile->op) { /* fails on reload */ if (RNA_struct_find_property(sfile->op->ptr, "check_existing")) { if (RNA_boolean_get(sfile->op->ptr, "check_existing")) { char filepath[FILE_MAX]; BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file); if (BLI_is_file(filepath)) { return true; } } } } return false; }
static int fluidsim_find_lastframe(Object *ob, FluidsimSettings *fss) { char targetFileTest[FILE_MAX]; char targetFile[FILE_MAX]; int curFrame = 1; BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME); BLI_path_abs(targetFile, modifier_path_relbase(ob)); do { BLI_strncpy(targetFileTest, targetFile, sizeof(targetFileTest)); BLI_path_frame(targetFileTest, curFrame++, 0); } while (BLI_exists(targetFileTest)); return curFrame - 1; }
static WorkspaceConfigFileData *workspace_system_file_read(const char *app_template) { if (app_template == NULL) { return BKE_blendfile_workspace_config_read( NULL, datatoc_startup_blend, datatoc_startup_blend_size, NULL); } char template_dir[FILE_MAX]; if (!BKE_appdir_app_template_id_search(app_template, template_dir, sizeof(template_dir))) { return NULL; } char startup_file_path[FILE_MAX]; BLI_join_dirfile( startup_file_path, sizeof(startup_file_path), template_dir, BLENDER_STARTUP_FILE); bool has_path = BLI_exists(startup_file_path); return (has_path) ? BKE_blendfile_workspace_config_read(startup_file_path, NULL, 0, NULL) : NULL; }
static void cache_filename(char *string, const char *path, const char *relbase, int frame, int type) { char cachepath[FILE_MAX]; const char *fname; switch (type) { case CACHE_TYPE_FOAM: fname = "foam_"; break; case CACHE_TYPE_NORMAL: fname = "normal_"; break; case CACHE_TYPE_DISPLACE: default: fname = "disp_"; break; } BLI_join_dirfile(cachepath, sizeof(cachepath), path, fname); BKE_makepicstring_from_type(string, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, 1, TRUE); }
char *blf_dir_search(const char *file) { DirBLF *dir; char full_path[FILE_MAX]; 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_exists(full_path)) { s = BLI_strdup(full_path); break; } } if (!s) { /* check the current directory, why not ? */ if (BLI_exists(file)) s = BLI_strdup(file); } return s; }
/** When this method is called, the writer must write the image. @return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeImage( const COLLADAFW::Image* image ) { if(mImportStage!=General) return true; // XXX maybe it is necessary to check if the path is absolute or relative const std::string& filepath = image->getImageURI().toNativePath(); const char *filename = (const char*)mFilename.c_str(); char dir[FILE_MAX]; char full_path[FILE_MAX]; BLI_split_dirfile(filename, dir, NULL, sizeof(dir), 0); BLI_join_dirfile(full_path, sizeof(full_path), dir, filepath.c_str()); Image *ima = BKE_add_image_file(full_path); if (!ima) { fprintf(stderr, "Cannot create image. \n"); return true; } this->uid_image_map[image->getUniqueId()] = ima; return true; }
/* * Do actual bake operation. Loop through to-be-baked frames. * Returns 0 on failure. */ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) { DynamicPaintSurface *surface = job->surface; Object *cObject = job->ob; DynamicPaintCanvasSettings *canvas = surface->canvas; Scene *scene = job->scene; int frame = 1, orig_frame; int frames; frames = surface->end_frame - surface->start_frame + 1; if (frames <= 0) { BLI_strncpy(canvas->error, N_("No frames to bake"), sizeof(canvas->error)); return; } /* Show progress bar. */ *(job->do_update) = true; /* Set frame to start point (also inits modifier data) */ frame = surface->start_frame; orig_frame = scene->r.cfra; scene->r.cfra = (int)frame; ED_update_for_newframe(job->bmain, scene, 1); /* Init surface */ if (!dynamicPaint_createUVSurface(scene, surface, job->progress, job->do_update)) { job->success = 0; return; } /* Loop through selected frames */ for (frame = surface->start_frame; frame <= surface->end_frame; frame++) { /* The first 10% are for createUVSurface... */ const float progress = 0.1f + 0.9f * (frame - surface->start_frame) / (float)frames; surface->current_frame = frame; /* If user requested stop, quit baking */ if (G.is_break) { job->success = 0; return; } /* Update progress bar */ *(job->do_update) = true; *(job->progress) = progress; /* calculate a frame */ scene->r.cfra = (int)frame; ED_update_for_newframe(job->bmain, scene, 1); if (!dynamicPaint_calculateFrame(surface, scene, cObject, frame)) { job->success = 0; return; } /* * Save output images */ { char filename[FILE_MAX]; /* primary output layer */ if (surface->flags & MOD_DPAINT_OUT1) { /* set filepath */ BLI_join_dirfile(filename, sizeof(filename), surface->image_output_path, surface->output_name); BLI_path_frame(filename, frame, 4); /* save image */ dynamicPaint_outputSurfaceImage(surface, filename, 0); } /* secondary output */ if (surface->flags & MOD_DPAINT_OUT2 && surface->type == MOD_DPAINT_SURFACE_T_PAINT) { /* set filepath */ BLI_join_dirfile(filename, sizeof(filename), surface->image_output_path, surface->output_name2); BLI_path_frame(filename, frame, 4); /* save image */ dynamicPaint_outputSurfaceImage(surface, filename, 1); } } } scene->r.cfra = orig_frame; }