diff --git a/intern/cycles/blender/util.h b/intern/cycles/blender/util.h index c2b94cece35..c216ef1639c 100644 --- a/intern/cycles/blender/util.h +++ b/intern/cycles/blender/util.h @@ -21,8 +21,12 @@ extern "C" { void BKE_image_user_frame_calc(void *ima, void *iuser, int cfra); -void BKE_image_user_file_path_ex( - void *bmain, void *iuser, void *ima, char *path, bool resolve_udim, bool resolve_multiview); +void BKE_image_user_file_path_ex(void *bmain, + void *iuser, + void *ima, + char *filepath, + bool resolve_udim, + bool resolve_multiview); unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame, int tile); float *BKE_image_get_float_pixels_for_frame(void *image, int frame, int tile); } diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 73c69d901e1..fc399e47271 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -43,7 +43,7 @@ void blf_batch_draw(void); unsigned int blf_next_p2(unsigned int x); unsigned int blf_hash(unsigned int val); -char *blf_dir_search(const char *file); +char *blf_dir_search(const char *filepath); /** * Some font have additional file with metrics information, * in general, the extension of the file is: `.afm` or `.pfm` diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 8fe510e119b..fc602e6bffb 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -86,29 +86,29 @@ bool BKE_imbuf_alpha_test(struct ImBuf *ibuf); int BKE_imbuf_write_stamp(const struct Scene *scene, const struct RenderResult *rr, struct ImBuf *ibuf, - const char *name, + const char *filepath, const struct ImageFormatData *imf); /** * \note imf->planes is ignored here, its assumed the image channels are already set. */ -int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, const struct ImageFormatData *imf); +int BKE_imbuf_write(struct ImBuf *ibuf, const char *filepath, const struct ImageFormatData *imf); /** * Same as #BKE_imbuf_write() but crappy workaround not to permanently modify _some_, * values in the imbuf. */ int BKE_imbuf_write_as(struct ImBuf *ibuf, - const char *name, + const char *filepath, const struct ImageFormatData *imf, bool save_copy); /** * Used by sequencer too. */ -struct anim *openanim(const char *name, +struct anim *openanim(const char *filepath, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]); -struct anim *openanim_noload(const char *name, +struct anim *openanim_noload(const char *filepath, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]); @@ -237,11 +237,13 @@ void BKE_image_ensure_viewer_views(const struct RenderData *rd, */ void BKE_image_user_frame_calc(struct Image *ima, struct ImageUser *iuser, int cfra); int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, bool *r_is_in_range); -void BKE_image_user_file_path(const struct ImageUser *iuser, const struct Image *ima, char *path); +void BKE_image_user_file_path(const struct ImageUser *iuser, + const struct Image *ima, + char *filepath); void BKE_image_user_file_path_ex(const struct Main *bmain, const struct ImageUser *iuser, const struct Image *ima, - char *path, + char *filepath, const bool resolve_udim, const bool resolve_multiview); void BKE_image_editors_update_frame(const struct Main *bmain, int cfra); @@ -477,7 +479,7 @@ bool BKE_image_has_loaded_ibuf(struct Image *image); * References the result, #BKE_image_release_ibuf is to be called to de-reference. * Use lock=NULL when calling #BKE_image_release_ibuf(). */ -struct ImBuf *BKE_image_get_ibuf_with_name(struct Image *image, const char *name); +struct ImBuf *BKE_image_get_ibuf_with_name(struct Image *image, const char *filepath); /** * References the result, #BKE_image_release_ibuf is to be called to de-reference. * Use lock=NULL when calling #BKE_image_release_ibuf(). diff --git a/source/blender/blenkernel/BKE_image_format.h b/source/blender/blenkernel/BKE_image_format.h index e3254c59ca4..d742a82159d 100644 --- a/source/blender/blenkernel/BKE_image_format.h +++ b/source/blender/blenkernel/BKE_image_format.h @@ -29,7 +29,7 @@ void BKE_image_format_blend_write(struct BlendWriter *writer, struct ImageFormat /* File Paths */ -void BKE_image_path_from_imformat(char *string, +void BKE_image_path_from_imformat(char *filepath, const char *base, const char *relbase, int frame, @@ -37,7 +37,7 @@ void BKE_image_path_from_imformat(char *string, bool use_ext, bool use_frames, const char *suffix); -void BKE_image_path_from_imtype(char *string, +void BKE_image_path_from_imtype(char *filepath, const char *base, const char *relbase, int frame, @@ -45,8 +45,9 @@ void BKE_image_path_from_imtype(char *string, bool use_ext, bool use_frames, const char *suffix); -int BKE_image_path_ensure_ext_from_imformat(char *string, const struct ImageFormatData *im_format); -int BKE_image_path_ensure_ext_from_imtype(char *string, char imtype); +int BKE_image_path_ensure_ext_from_imformat(char *filepath, + const struct ImageFormatData *im_format); +int BKE_image_path_ensure_ext_from_imtype(char *filepath, char imtype); /* File Types */ diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index 893aa2a5b1c..63b809a708e 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -45,7 +45,7 @@ enum ePF_FileStatus { struct PackedFile *BKE_packedfile_duplicate(const struct PackedFile *pf_src); struct PackedFile *BKE_packedfile_new(struct ReportList *reports, - const char *filepath, + const char *filepath_rel, const char *basepath); struct PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen); diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h index 0dff56ee60b..f9ac5caeee9 100644 --- a/source/blender/blenkernel/BKE_studiolight.h +++ b/source/blender/blenkernel/BKE_studiolight.h @@ -99,7 +99,7 @@ typedef struct StudioLight { int index; int flag; char name[FILE_MAXFILE]; - char path[FILE_MAX]; + char filepath[FILE_MAX]; char *path_irr_cache; char *path_sh_cache; int icon_id_irradiance; @@ -142,8 +142,8 @@ struct ListBase *BKE_studiolight_listbase(void); */ void BKE_studiolight_ensure_flag(StudioLight *sl, int flag); void BKE_studiolight_refresh(void); -StudioLight *BKE_studiolight_load(const char *path, int type); -StudioLight *BKE_studiolight_create(const char *path, +StudioLight *BKE_studiolight_load(const char *filepath, int type); +StudioLight *BKE_studiolight_create(const char *filepath, const SolidLight light[4], const float light_ambient[3]); /** diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index e1bbffb11e1..b6391b74fc3 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -38,7 +38,7 @@ typedef struct bMovieHandle { void (*end_movie)(void *context_v); /* Optional function. */ - void (*get_movie_path)(char *string, + void (*get_movie_path)(char *filepath, const struct RenderData *rd, bool preview, const char *suffix); @@ -52,7 +52,7 @@ bMovieHandle *BKE_movie_handle_get(char imtype); /** * \note Similar to #BKE_image_path_from_imformat() */ -void BKE_movie_filepath_get(char *string, +void BKE_movie_filepath_get(char *filepath, const struct RenderData *rd, bool preview, const char *suffix); diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index cfe246eb470..d5cc6e0a4de 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -64,7 +64,7 @@ int BKE_ffmpeg_append(void *context_v, int recty, const char *suffix, struct ReportList *reports); -void BKE_ffmpeg_filepath_get(char *string, +void BKE_ffmpeg_filepath_get(char *filepath, const struct RenderData *rd, bool preview, const char *suffix); diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index 8bb0a70a912..c7ed3721779 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -812,13 +812,13 @@ const char *BKE_appdir_resource_path_id(const int folder_id, const bool check_is * adds the correct extension (`.com` `.exe` etc) from * `$PATHEXT` if necessary. Also on Windows it translates * the name to its 8.3 version to prevent problems with - * spaces and stuff. Final result is returned in \a fullname. + * spaces and stuff. Final result is returned in \a program_filepath. * - * \param fullname: The full path and full name of the executable + * \param program_filepath: The full path and full name of the executable * (must be #FILE_MAX minimum) * \param name: The name of the executable (usually `argv[0]`) to be checked */ -static void where_am_i(char *fullname, const size_t maxlen, const char *name) +static void where_am_i(char *program_filepath, const size_t maxlen, const char *program_name) { # ifdef WITH_BINRELOC /* Linux uses `binreloc` since `argv[0]` is not reliable, call `br_init(NULL)` first. */ @@ -826,7 +826,7 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) const char *path = NULL; path = br_find_exe(NULL); if (path) { - BLI_strncpy(fullname, path, maxlen); + BLI_strncpy(program_filepath, path, maxlen); free((void *)path); return; } @@ -837,9 +837,9 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) { wchar_t *fullname_16 = MEM_mallocN(maxlen * sizeof(wchar_t), "ProgramPath"); if (GetModuleFileNameW(0, fullname_16, maxlen)) { - conv_utf_16_to_8(fullname_16, fullname, maxlen); - if (!BLI_exists(fullname)) { - CLOG_ERROR(&LOG, "path can't be found: \"%.*s\"", (int)maxlen, fullname); + conv_utf_16_to_8(fullname_16, program_filepath, maxlen); + if (!BLI_exists(program_filepath)) { + CLOG_ERROR(&LOG, "path can't be found: \"%.*s\"", (int)maxlen, program_filepath); MessageBox( NULL, "path contains invalid characters or is too long (see console)", "Error", MB_OK); } @@ -852,31 +852,31 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) # endif /* Unix and non Linux. */ - if (name && name[0]) { + if (program_name && program_name[0]) { - BLI_strncpy(fullname, name, maxlen); - if (name[0] == '.') { - BLI_path_abs_from_cwd(fullname, maxlen); + BLI_strncpy(program_filepath, program_name, maxlen); + if (program_name[0] == '.') { + BLI_path_abs_from_cwd(program_filepath, maxlen); # ifdef _WIN32 - BLI_path_program_extensions_add_win32(fullname, maxlen); + BLI_path_program_extensions_add_win32(program_filepath, maxlen); # endif } - else if (BLI_path_slash_rfind(name)) { + else if (BLI_path_slash_rfind(program_name)) { /* Full path. */ - BLI_strncpy(fullname, name, maxlen); + BLI_strncpy(program_filepath, program_name, maxlen); # ifdef _WIN32 - BLI_path_program_extensions_add_win32(fullname, maxlen); + BLI_path_program_extensions_add_win32(program_filepath, maxlen); # endif } else { - BLI_path_program_search(fullname, maxlen, name); + BLI_path_program_search(program_filepath, maxlen, program_name); } /* Remove "/./" and "/../" so string comparisons can be used on the path. */ - BLI_path_normalize(fullname); + BLI_path_normalize(program_filepath); # if defined(DEBUG) - if (!STREQ(name, fullname)) { - CLOG_INFO(&LOG, 2, "guessing '%s' == '%s'", name, fullname); + if (!STREQ(program_name, program_filepath)) { + CLOG_INFO(&LOG, 2, "guessing '%s' == '%s'", program_name, program_filepath); } # endif } @@ -921,8 +921,8 @@ const char *BKE_appdir_program_dir(void) return g_app.program_dirname; } -bool BKE_appdir_program_python_search(char *fullpath, - const size_t fullpath_len, +bool BKE_appdir_program_python_search(char *program_filepath, + const size_t program_filepath_maxncpy, const int version_major, const int version_minor) { @@ -957,13 +957,13 @@ bool BKE_appdir_program_python_search(char *fullpath, if (python_bin_dir) { for (int i = 0; i < ARRAY_SIZE(python_names); i++) { - BLI_path_join(fullpath, fullpath_len, python_bin_dir, python_names[i]); + BLI_path_join(program_filepath, program_filepath_maxncpy, python_bin_dir, python_names[i]); if ( #ifdef _WIN32 - BLI_path_program_extensions_add_win32(fullpath, fullpath_len) + BLI_path_program_extensions_add_win32(program_filepath, program_filepath_maxncpy) #else - BLI_exists(fullpath) + BLI_exists(program_filepath) #endif ) { @@ -976,7 +976,7 @@ bool BKE_appdir_program_python_search(char *fullpath, if (is_found == false) { for (int i = 0; i < ARRAY_SIZE(python_names); i++) { - if (BLI_path_program_search(fullpath, fullpath_len, python_names[i])) { + if (BLI_path_program_search(program_filepath, program_filepath_maxncpy, python_names[i])) { is_found = true; break; } @@ -984,7 +984,7 @@ bool BKE_appdir_program_python_search(char *fullpath, } if (is_found == false) { - *fullpath = '\0'; + *program_filepath = '\0'; } return is_found; diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index bc1f9d08fe1..d9bd0548931 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -976,12 +976,12 @@ int BKE_image_find_nearest_tile(const struct Image *image, const float co[2]) static void image_init_color_management(Image *ima) { ImBuf *ibuf; - char name[FILE_MAX]; + char filepath[FILE_MAX]; - BKE_image_user_file_path(nullptr, ima, name); + BKE_image_user_file_path(nullptr, ima, filepath); /* Will set input color space to image format default's. */ - ibuf = IMB_loadiffname(name, IB_test | IB_alphamode_detect, ima->colorspace_settings.name); + ibuf = IMB_loadiffname(filepath, IB_test | IB_alphamode_detect, ima->colorspace_settings.name); if (ibuf) { if (ibuf->flags & IB_alphamode_premul) { @@ -1019,15 +1019,15 @@ Image *BKE_image_load(Main *bmain, const char *filepath) { Image *ima; int file; - char str[FILE_MAX]; + char filepath_abs[FILE_MAX]; - STRNCPY(str, filepath); - BLI_path_abs(str, BKE_main_blendfile_path(bmain)); + STRNCPY(filepath_abs, filepath); + BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain)); /* exists? */ - file = BLI_open(str, O_BINARY | O_RDONLY, 0); + file = BLI_open(filepath_abs, O_BINARY | O_RDONLY, 0); if (file == -1) { - if (!BKE_image_tile_filepath_exists(str)) { + if (!BKE_image_tile_filepath_exists(filepath_abs)) { return nullptr; } } @@ -1050,20 +1050,20 @@ Image *BKE_image_load(Main *bmain, const char *filepath) Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exists) { Image *ima; - char str[FILE_MAX], strtest[FILE_MAX]; + char filepath_abs[FILE_MAX], filepath_test[FILE_MAX]; - STRNCPY(str, filepath); - BLI_path_abs(str, bmain->filepath); + STRNCPY(filepath_abs, filepath); + BLI_path_abs(filepath_abs, bmain->filepath); /* first search an identical filepath */ for (ima = static_cast(bmain->images.first); ima; ima = static_cast(ima->id.next)) { if (!ELEM(ima->source, IMA_SRC_VIEWER, IMA_SRC_GENERATED)) { - STRNCPY(strtest, ima->filepath); - BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id)); + STRNCPY(filepath_test, ima->filepath); + BLI_path_abs(filepath_test, ID_BLEND_PATH(bmain, &ima->id)); - if (BLI_path_cmp(strtest, str) == 0) { + if (BLI_path_cmp(filepath_test, filepath_abs) == 0) { if ((BKE_image_has_anim(ima) == false) || (ima->id.us == 0)) { id_us_plus(&ima->id); /* officially should not, it doesn't link here! */ if (r_exists) { @@ -1173,7 +1173,7 @@ static ImBuf *add_ibuf_for_tile(Image *ima, ImageTile *tile) return nullptr; } - STRNCPY(ibuf->name, ima->filepath); + STRNCPY(ibuf->filepath, ima->filepath); /* Mark the tile itself as having been generated. */ tile->gen_flag |= IMA_GEN_TILE; @@ -1286,13 +1286,13 @@ static void image_colorspace_from_imbuf(Image *image, const ImBuf *ibuf) Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name) { if (name == nullptr) { - name = BLI_path_basename(ibuf->name); + name = BLI_path_basename(ibuf->filepath); } /* When the image buffer has valid path create a new image with "file" source and copy the path * from the image buffer. * Otherwise create "generated" image, avoiding invalid configuration with an empty file path. */ - const eImageSource source = ibuf->name[0] != '\0' ? IMA_SRC_FILE : IMA_SRC_GENERATED; + const eImageSource source = ibuf->filepath[0] != '\0' ? IMA_SRC_FILE : IMA_SRC_GENERATED; Image *ima = image_alloc(bmain, name, source, IMA_TYPE_IMAGE); @@ -1392,7 +1392,7 @@ bool BKE_image_memorypack(Image *ima) break; } - const char *filepath = ibuf->name; + const char *filepath = ibuf->filepath; if (is_tiled) { iuser.tile = tile->tile_number; BKE_image_user_file_path(&iuser, ima, tiled_filepath); @@ -2550,22 +2550,22 @@ bool BKE_imbuf_alpha_test(ImBuf *ibuf) return false; } -int BKE_imbuf_write(ImBuf *ibuf, const char *name, const ImageFormatData *imf) +int BKE_imbuf_write(ImBuf *ibuf, const char *filepath, const ImageFormatData *imf) { BKE_image_format_to_imbuf(ibuf, imf); - BLI_file_ensure_parent_dir_exists(name); + BLI_file_ensure_parent_dir_exists(filepath); - const bool ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); + const bool ok = IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == 0) { - perror(name); + perror(filepath); } return ok; } int BKE_imbuf_write_as(ImBuf *ibuf, - const char *name, + const char *filepath, const ImageFormatData *imf, const bool save_copy) { @@ -2575,7 +2575,7 @@ int BKE_imbuf_write_as(ImBuf *ibuf, /* All data is RGBA anyway, this just controls how to save for some formats. */ ibuf->planes = imf->planes; - ok = BKE_imbuf_write(ibuf, name, imf); + ok = BKE_imbuf_write(ibuf, filepath, imf); if (save_copy) { /* note that we are not restoring _all_ settings */ @@ -2590,44 +2590,47 @@ int BKE_imbuf_write_as(ImBuf *ibuf, int BKE_imbuf_write_stamp(const Scene *scene, const struct RenderResult *rr, ImBuf *ibuf, - const char *name, + const char *filepath, const struct ImageFormatData *imf) { if (scene && scene->r.stamp & R_STAMP_ALL) { BKE_imbuf_stamp_info(rr, ibuf); } - return BKE_imbuf_write(ibuf, name, imf); + return BKE_imbuf_write(ibuf, filepath, imf); } -struct anim *openanim_noload(const char *name, +struct anim *openanim_noload(const char *filepath, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]) { struct anim *anim; - anim = IMB_open_anim(name, flags, streamindex, colorspace); + anim = IMB_open_anim(filepath, flags, streamindex, colorspace); return anim; } -struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]) +struct anim *openanim(const char *filepath, + int flags, + int streamindex, + char colorspace[IMA_MAX_SPACE]) { struct anim *anim; struct ImBuf *ibuf; - anim = IMB_open_anim(name, flags, streamindex, colorspace); + anim = IMB_open_anim(filepath, flags, streamindex, colorspace); if (anim == nullptr) { return nullptr; } ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); if (ibuf == nullptr) { - if (BLI_exists(name)) { - printf("not an anim: %s\n", name); + if (BLI_exists(filepath)) { + printf("not an anim: %s\n", filepath); } else { - printf("anim file doesn't exist: %s\n", name); + printf("anim file doesn't exist: %s\n", filepath); } IMB_free_anim(anim); return nullptr; @@ -4020,7 +4023,7 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i ia = static_cast(BLI_findlink(&ima->anims, view_id)); if (ia->anim == nullptr) { - char str[FILE_MAX]; + char filepath[FILE_MAX]; int flags = IB_rect; ImageUser iuser_t{}; @@ -4034,10 +4037,10 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i iuser_t.view = view_id; - BKE_image_user_file_path(&iuser_t, ima, str); + BKE_image_user_file_path(&iuser_t, ima, filepath); /* FIXME: make several stream accessible in image editor, too. */ - ia->anim = openanim(str, flags, 0, ima->colorspace_settings.name); + ia->anim = openanim(filepath, flags, 0, ima->colorspace_settings.name); /* let's initialize this user */ if (ia->anim && iuser && iuser->frames == 0) { @@ -5425,7 +5428,7 @@ bool BKE_image_has_loaded_ibuf(Image *image) return has_loaded_ibuf; } -ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name) +ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *filepath) { ImBuf *ibuf = nullptr; @@ -5435,7 +5438,7 @@ ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name) while (!IMB_moviecacheIter_done(iter)) { ImBuf *current_ibuf = IMB_moviecacheIter_getImBuf(iter); - if (current_ibuf != nullptr && STREQ(current_ibuf->name, name)) { + if (current_ibuf != nullptr && STREQ(current_ibuf->filepath, filepath)) { ibuf = current_ibuf; IMB_refImBuf(ibuf); break; @@ -5496,10 +5499,10 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) else { /* R_IMF_VIEWS_INDIVIDUAL */ char prefix[FILE_MAX] = {'\0'}; - char *name = ima->filepath; + char *filepath = ima->filepath; const char *ext = nullptr; - BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext); + BKE_scene_multiview_view_prefix_get(scene, filepath, prefix, &ext); if (prefix[0] == '\0') { BKE_image_free_views(ima); @@ -5509,9 +5512,9 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) /* create all the image views */ for (srv = static_cast(scene->r.views.first); srv; srv = srv->next) { if (BKE_scene_multiview_is_render_view_active(&scene->r, srv)) { - char filepath[FILE_MAX]; - SNPRINTF(filepath, "%s%s%s", prefix, srv->suffix, ext); - image_add_view(ima, srv->name, filepath); + char filepath_view[FILE_MAX]; + SNPRINTF(filepath_view, "%s%s%s", prefix, srv->suffix, ext); + image_add_view(ima, srv->name, filepath_view); } } @@ -5519,13 +5522,13 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) iv = static_cast(ima->views.last); while (iv) { int file; - char str[FILE_MAX]; + char filepath[FILE_MAX]; - STRNCPY(str, iv->filepath); - BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); + STRNCPY(filepath, iv->filepath); + BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); /* exists? */ - file = BLI_open(str, O_BINARY | O_RDONLY, 0); + file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { ImageView *iv_del = iv; iv = iv->prev; diff --git a/source/blender/blenkernel/intern/image_format.cc b/source/blender/blenkernel/intern/image_format.cc index d5af7310b2f..c508e034ab6 100644 --- a/source/blender/blenkernel/intern/image_format.cc +++ b/source/blender/blenkernel/intern/image_format.cc @@ -386,7 +386,7 @@ char BKE_imtype_from_arg(const char *imtype_arg) /* File Paths */ -static bool do_add_image_extension(char *string, +static bool do_add_image_extension(char *filepath, const char imtype, const ImageFormatData *im_format) { @@ -395,17 +395,17 @@ static bool do_add_image_extension(char *string, (void)im_format; /* may be unused, depends on build options */ if (imtype == R_IMF_IMTYPE_IRIS) { - if (!BLI_path_extension_check(string, extension_test = ".rgb")) { + if (!BLI_path_extension_check(filepath, extension_test = ".rgb")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_IRIZ) { - if (!BLI_path_extension_check(string, extension_test = ".rgb")) { + if (!BLI_path_extension_check(filepath, extension_test = ".rgb")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_RADHDR) { - if (!BLI_path_extension_check(string, extension_test = ".hdr")) { + if (!BLI_path_extension_check(filepath, extension_test = ".hdr")) { extension = extension_test; } } @@ -417,50 +417,50 @@ static bool do_add_image_extension(char *string, R_IMF_IMTYPE_XVID, R_IMF_IMTYPE_AV1)) { - if (!BLI_path_extension_check(string, extension_test = ".png")) { + if (!BLI_path_extension_check(filepath, extension_test = ".png")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_DDS) { - if (!BLI_path_extension_check(string, extension_test = ".dds")) { + if (!BLI_path_extension_check(filepath, extension_test = ".dds")) { extension = extension_test; } } else if (ELEM(imtype, R_IMF_IMTYPE_TARGA, R_IMF_IMTYPE_RAWTGA)) { - if (!BLI_path_extension_check(string, extension_test = ".tga")) { + if (!BLI_path_extension_check(filepath, extension_test = ".tga")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_BMP) { - if (!BLI_path_extension_check(string, extension_test = ".bmp")) { + if (!BLI_path_extension_check(filepath, extension_test = ".bmp")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_TIFF) { - if (!BLI_path_extension_check_n(string, extension_test = ".tif", ".tiff", nullptr)) { + if (!BLI_path_extension_check_n(filepath, extension_test = ".tif", ".tiff", nullptr)) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_PSD) { - if (!BLI_path_extension_check(string, extension_test = ".psd")) { + if (!BLI_path_extension_check(filepath, extension_test = ".psd")) { extension = extension_test; } } #ifdef WITH_OPENEXR else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { - if (!BLI_path_extension_check(string, extension_test = ".exr")) { + if (!BLI_path_extension_check(filepath, extension_test = ".exr")) { extension = extension_test; } } #endif #ifdef WITH_CINEON else if (imtype == R_IMF_IMTYPE_CINEON) { - if (!BLI_path_extension_check(string, extension_test = ".cin")) { + if (!BLI_path_extension_check(filepath, extension_test = ".cin")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_DPX) { - if (!BLI_path_extension_check(string, extension_test = ".dpx")) { + if (!BLI_path_extension_check(filepath, extension_test = ".dpx")) { extension = extension_test; } } @@ -469,12 +469,12 @@ static bool do_add_image_extension(char *string, else if (imtype == R_IMF_IMTYPE_JP2) { if (im_format) { if (im_format->jp2_codec == R_IMF_JP2_CODEC_JP2) { - if (!BLI_path_extension_check(string, extension_test = ".jp2")) { + if (!BLI_path_extension_check(filepath, extension_test = ".jp2")) { extension = extension_test; } } else if (im_format->jp2_codec == R_IMF_JP2_CODEC_J2K) { - if (!BLI_path_extension_check(string, extension_test = ".j2c")) { + if (!BLI_path_extension_check(filepath, extension_test = ".j2c")) { extension = extension_test; } } @@ -483,7 +483,7 @@ static bool do_add_image_extension(char *string, } } else { - if (!BLI_path_extension_check(string, extension_test = ".jp2")) { + if (!BLI_path_extension_check(filepath, extension_test = ".jp2")) { extension = extension_test; } } @@ -491,13 +491,13 @@ static bool do_add_image_extension(char *string, #endif #ifdef WITH_WEBP else if (imtype == R_IMF_IMTYPE_WEBP) { - if (!BLI_path_extension_check(string, extension_test = ".webp")) { + if (!BLI_path_extension_check(filepath, extension_test = ".webp")) { extension = extension_test; } } #endif else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90 etc - if (!BLI_path_extension_check_n(string, extension_test = ".jpg", ".jpeg", nullptr)) { + if (!BLI_path_extension_check_n(filepath, extension_test = ".jpg", ".jpeg", nullptr)) { extension = extension_test; } } @@ -505,27 +505,27 @@ static bool do_add_image_extension(char *string, if (extension) { /* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */ /* remove any other known image extension */ - if (BLI_path_extension_check_array(string, imb_ext_image)) { - return BLI_path_extension_replace(string, FILE_MAX, extension); + if (BLI_path_extension_check_array(filepath, imb_ext_image)) { + return BLI_path_extension_replace(filepath, FILE_MAX, extension); } - return BLI_path_extension_ensure(string, FILE_MAX, extension); + return BLI_path_extension_ensure(filepath, FILE_MAX, extension); } return false; } -int BKE_image_path_ensure_ext_from_imformat(char *string, const ImageFormatData *im_format) +int BKE_image_path_ensure_ext_from_imformat(char *filepath, const ImageFormatData *im_format) { - return do_add_image_extension(string, im_format->imtype, im_format); + return do_add_image_extension(filepath, im_format->imtype, im_format); } -int BKE_image_path_ensure_ext_from_imtype(char *string, const char imtype) +int BKE_image_path_ensure_ext_from_imtype(char *filepath, const char imtype) { - return do_add_image_extension(string, imtype, nullptr); + return do_add_image_extension(filepath, imtype, nullptr); } -static void do_makepicstring(char string[FILE_MAX], +static void do_makepicstring(char filepath[FILE_MAX], const char *base, const char *relbase, int frame, @@ -535,26 +535,26 @@ static void do_makepicstring(char string[FILE_MAX], const bool use_frames, const char *suffix) { - if (string == nullptr) { + if (filepath == nullptr) { return; } - BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ - BLI_path_abs(string, relbase); + BLI_strncpy(filepath, base, FILE_MAX - 10); /* weak assumption */ + BLI_path_abs(filepath, relbase); if (use_frames) { - BLI_path_frame(string, FILE_MAX, frame, 4); + BLI_path_frame(filepath, FILE_MAX, frame, 4); } if (suffix) { - BLI_path_suffix(string, FILE_MAX, suffix, ""); + BLI_path_suffix(filepath, FILE_MAX, suffix, ""); } if (use_ext) { - do_add_image_extension(string, imtype, im_format); + do_add_image_extension(filepath, imtype, im_format); } } -void BKE_image_path_from_imformat(char *string, +void BKE_image_path_from_imformat(char *filepath, const char *base, const char *relbase, int frame, @@ -564,10 +564,10 @@ void BKE_image_path_from_imformat(char *string, const char *suffix) { do_makepicstring( - string, base, relbase, frame, im_format->imtype, im_format, use_ext, use_frames, suffix); + filepath, base, relbase, frame, im_format->imtype, im_format, use_ext, use_frames, suffix); } -void BKE_image_path_from_imtype(char *string, +void BKE_image_path_from_imtype(char *filepath, const char *base, const char *relbase, int frame, @@ -576,7 +576,7 @@ void BKE_image_path_from_imtype(char *string, const bool use_frames, const char *suffix) { - do_makepicstring(string, base, relbase, frame, imtype, nullptr, use_ext, use_frames, suffix); + do_makepicstring(filepath, base, relbase, frame, imtype, nullptr, use_ext, use_frames, suffix); } /* ImBuf Conversion */ diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 69dad6147d2..83e32c39084 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -281,7 +281,7 @@ static void image_save_post(ReportList *reports, } if (opts->do_newpath) { - BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); } /* The tiled image code-path must call this on its own. */ @@ -350,7 +350,7 @@ static void imbuf_save_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf) /** * \return success. - * \note `ima->filepath` and `ibuf->name` should end up the same. + * \note `ima->filepath` and `ibuf->filepath` should end up the same. * \note for multi-view the first `ibuf` is important to get the settings. */ static bool image_save_single(ReportList *reports, diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 65dab0c9984..312e1357f79 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -1120,8 +1120,8 @@ void BKE_ocean_free(struct Ocean *oc) # define CACHE_TYPE_SPRAY 4 # define CACHE_TYPE_SPRAY_INVERSE 5 -static void cache_filename( - char *string, const char *path, const char *relbase, int frame, int type) +static void cache_filepath( + char *filepath, const char *dirname, const char *relbase, int frame, int type) { char cachepath[FILE_MAX]; const char *fname; @@ -1145,10 +1145,10 @@ static void cache_filename( break; } - BLI_path_join(cachepath, sizeof(cachepath), path, fname); + BLI_path_join(cachepath, sizeof(cachepath), dirname, fname); BKE_image_path_from_imtype( - string, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, true, true, ""); + filepath, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, true, true, ""); } /* silly functions but useful to inline when the args do a lot of indirections */ @@ -1346,7 +1346,7 @@ struct OceanCache *BKE_ocean_init_cache(const char *bakepath, void BKE_ocean_simulate_cache(struct OceanCache *och, int frame) { - char string[FILE_MAX]; + char filepath[FILE_MAX]; int f = frame; /* ibufs array is zero based, but filenames are based on frame numbers */ @@ -1362,20 +1362,20 @@ void BKE_ocean_simulate_cache(struct OceanCache *och, int frame) /* Use default color spaces since we know for sure cache * files were saved with default settings too. */ - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE); - och->ibufs_disp[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE); + och->ibufs_disp[f] = IMB_loadiffname(filepath, 0, NULL); - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM); - och->ibufs_foam[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM); + och->ibufs_foam[f] = IMB_loadiffname(filepath, 0, NULL); - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY); - och->ibufs_spray[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY); + och->ibufs_spray[f] = IMB_loadiffname(filepath, 0, NULL); - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY_INVERSE); - och->ibufs_spray_inverse[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY_INVERSE); + och->ibufs_spray_inverse[f] = IMB_loadiffname(filepath, 0, NULL); - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL); - och->ibufs_norm[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL); + och->ibufs_norm[f] = IMB_loadiffname(filepath, 0, NULL); } void BKE_ocean_bake(struct Ocean *o, @@ -1396,7 +1396,7 @@ void BKE_ocean_bake(struct Ocean *o, float *prev_foam; int res_x = och->resolution_x; int res_y = och->resolution_y; - char string[FILE_MAX]; + char filepath[FILE_MAX]; // RNG *rng; if (!o) { @@ -1495,34 +1495,34 @@ void BKE_ocean_bake(struct Ocean *o, } /* write the images */ - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE); - if (0 == BKE_imbuf_write(ibuf_disp, string, &imf)) { - printf("Cannot save Displacement File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE); + if (0 == BKE_imbuf_write(ibuf_disp, filepath, &imf)) { + printf("Cannot save Displacement File Output to %s\n", filepath); } if (o->_do_jacobian) { - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM); - if (0 == BKE_imbuf_write(ibuf_foam, string, &imf)) { - printf("Cannot save Foam File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM); + if (0 == BKE_imbuf_write(ibuf_foam, filepath, &imf)) { + printf("Cannot save Foam File Output to %s\n", filepath); } if (o->_do_spray) { - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY); - if (0 == BKE_imbuf_write(ibuf_spray, string, &imf)) { - printf("Cannot save Spray File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY); + if (0 == BKE_imbuf_write(ibuf_spray, filepath, &imf)) { + printf("Cannot save Spray File Output to %s\n", filepath); } - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY_INVERSE); - if (0 == BKE_imbuf_write(ibuf_spray_inverse, string, &imf)) { - printf("Cannot save Spray Inverse File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY_INVERSE); + if (0 == BKE_imbuf_write(ibuf_spray_inverse, filepath, &imf)) { + printf("Cannot save Spray Inverse File Output to %s\n", filepath); } } } if (o->_do_normals) { - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL); - if (0 == BKE_imbuf_write(ibuf_normal, string, &imf)) { - printf("Cannot save Normal File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL); + if (0 == BKE_imbuf_write(ibuf_normal, filepath, &imf)) { + printf("Cannot save Normal File Output to %s\n", filepath); } } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index fc46635cbb4..b5e0a5d4268 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -174,16 +174,16 @@ PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen) return pf; } -PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath, const char *basepath) +PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath_rel, const char *basepath) { PackedFile *pf = NULL; int file, filelen; - char name[FILE_MAX]; + char filepath[FILE_MAX]; void *data; /* render result has no filepath and can be ignored * any other files with no name can be ignored too */ - if (filepath[0] == '\0') { + if (filepath_rel[0] == '\0') { return pf; } @@ -191,15 +191,15 @@ PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath, const /* convert relative filenames to absolute filenames */ - BLI_strncpy(name, filepath, sizeof(name)); - BLI_path_abs(name, basepath); + BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + BLI_path_abs(filepath, basepath); /* open the file * and create a PackedFile structure */ - file = BLI_open(name, O_BINARY | O_RDONLY, 0); + file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { - BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path '%s' not found", name); + BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path '%s' not found", filepath); } else { filelen = BLI_file_descriptor_size(file); @@ -285,28 +285,28 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose) int BKE_packedfile_write_to_file(ReportList *reports, const char *ref_file_name, - const char *filepath, + const char *filepath_rel, PackedFile *pf, const bool guimode) { int file, number; int ret_value = RET_OK; bool remove_tmp = false; - char name[FILE_MAX]; - char tempname[FILE_MAX]; + char filepath[FILE_MAX]; + char filepath_temp[FILE_MAX]; /* void *data; */ if (guimode) { } // XXX waitcursor(1); - BLI_strncpy(name, filepath, sizeof(name)); - BLI_path_abs(name, ref_file_name); + BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + BLI_path_abs(filepath, ref_file_name); - if (BLI_exists(name)) { + if (BLI_exists(filepath)) { for (number = 1; number <= 999; number++) { - BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number); - if (!BLI_exists(tempname)) { - if (BLI_copy(name, tempname) == RET_OK) { + BLI_snprintf(filepath_temp, sizeof(filepath_temp), "%s.%03d_", filepath, number); + if (!BLI_exists(filepath_temp)) { + if (BLI_copy(filepath, filepath_temp) == RET_OK) { remove_tmp = true; } break; @@ -314,20 +314,20 @@ int BKE_packedfile_write_to_file(ReportList *reports, } } - BLI_file_ensure_parent_dir_exists(name); + BLI_file_ensure_parent_dir_exists(filepath); - file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); + file = BLI_open(filepath, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); if (file == -1) { - BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", name); + BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", filepath); ret_value = RET_ERROR; } else { if (write(file, pf->data, pf->size) != pf->size) { - BKE_reportf(reports, RPT_ERROR, "Error writing file '%s'", name); + BKE_reportf(reports, RPT_ERROR, "Error writing file '%s'", filepath); ret_value = RET_ERROR; } else { - BKE_reportf(reports, RPT_INFO, "Saved packed file to: %s", name); + BKE_reportf(reports, RPT_INFO, "Saved packed file to: %s", filepath); } close(file); @@ -335,17 +335,17 @@ int BKE_packedfile_write_to_file(ReportList *reports, if (remove_tmp) { if (ret_value == RET_ERROR) { - if (BLI_rename(tempname, name) != 0) { + if (BLI_rename(filepath_temp, filepath) != 0) { BKE_reportf(reports, RPT_ERROR, "Error restoring temp file (check files '%s' '%s')", - tempname, - name); + filepath_temp, + filepath); } } else { - if (BLI_delete(tempname, false, false) != 0) { - BKE_reportf(reports, RPT_ERROR, "Error deleting '%s' (ignored)", tempname); + if (BLI_delete(filepath_temp, false, false) != 0) { + BKE_reportf(reports, RPT_ERROR, "Error deleting '%s' (ignored)", filepath_temp); } } } @@ -357,18 +357,18 @@ int BKE_packedfile_write_to_file(ReportList *reports, } enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, - const char *filepath, + const char *filepath_rel, PackedFile *pf) { BLI_stat_t st; enum ePF_FileCompare ret_val; char buf[4096]; - char name[FILE_MAX]; + char filepath[FILE_MAX]; - BLI_strncpy(name, filepath, sizeof(name)); - BLI_path_abs(name, ref_file_name); + BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + BLI_path_abs(filepath, ref_file_name); - if (BLI_stat(name, &st) == -1) { + if (BLI_stat(filepath, &st) == -1) { ret_val = PF_CMP_NOFILE; } else if (st.st_size != pf->size) { @@ -377,7 +377,7 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, else { /* we'll have to compare the two... */ - const int file = BLI_open(name, O_BINARY | O_RDONLY, 0); + const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { ret_val = PF_CMP_NOFILE; } @@ -478,7 +478,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports, return newname; } -static void unpack_generate_paths(const char *name, +static void unpack_generate_paths(const char *filepath, ID *id, char *r_abspath, char *r_relpath, @@ -486,15 +486,16 @@ static void unpack_generate_paths(const char *name, size_t relpathlen) { const short id_type = GS(id->name); - char tempname[FILE_MAX]; - char tempdir[FILE_MAXDIR]; + char temp_filename[FILE_MAX]; + char temp_dirname[FILE_MAXDIR]; - BLI_path_split_dir_file(name, tempdir, sizeof(tempdir), tempname, sizeof(tempname)); + BLI_path_split_dir_file( + filepath, temp_dirname, sizeof(temp_dirname), temp_filename, sizeof(temp_filename)); - if (tempname[0] == '\0') { + if (temp_filename[0] == '\0') { /* NOTE: we generally do not have any real way to re-create extension out of data. */ - const size_t len = BLI_strncpy_rlen(tempname, id->name + 2, sizeof(tempname)); - printf("%s\n", tempname); + const size_t len = BLI_strncpy_rlen(temp_filename, id->name + 2, sizeof(temp_filename)); + printf("%s\n", temp_filename); /* For images ensure that the temporary filename contains tile number information as well as * a file extension based on the file magic. */ @@ -507,22 +508,22 @@ static void unpack_generate_paths(const char *name, if (ima->source == IMA_SRC_TILED) { char tile_number[6]; BLI_snprintf(tile_number, sizeof(tile_number), ".%d", imapf->tile_number); - BLI_strncpy(tempname + len, tile_number, sizeof(tempname) - len); + BLI_strncpy(temp_filename + len, tile_number, sizeof(temp_filename) - len); } if (ftype != IMB_FTYPE_NONE) { const int imtype = BKE_ftype_to_imtype(ftype, NULL); - BKE_image_path_ensure_ext_from_imtype(tempname, imtype); + BKE_image_path_ensure_ext_from_imtype(temp_filename, imtype); } } } - BLI_path_make_safe_filename(tempname); - printf("%s\n", tempname); + BLI_path_make_safe_filename(temp_filename); + printf("%s\n", temp_filename); } - if (tempdir[0] == '\0') { + if (temp_dirname[0] == '\0') { /* Fallback to relative dir. */ - BLI_strncpy(tempdir, "//", sizeof(tempdir)); + BLI_strncpy(temp_dirname, "//", sizeof(temp_dirname)); } { @@ -544,13 +545,13 @@ static void unpack_generate_paths(const char *name, break; } if (dir_name) { - BLI_path_join(r_relpath, relpathlen, "//", dir_name, tempname); + BLI_path_join(r_relpath, relpathlen, "//", dir_name, temp_filename); } } { - size_t len = BLI_strncpy_rlen(r_abspath, tempdir, abspathlen); - BLI_strncpy(r_abspath + len, tempname, abspathlen - len); + size_t len = BLI_strncpy_rlen(r_abspath, temp_dirname, abspathlen); + BLI_strncpy(r_abspath + len, temp_filename, abspathlen - len); } } diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 400226ad972..458a4d9b0a0 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -141,7 +141,7 @@ static void studiolight_free(struct StudioLight *sl) static struct StudioLight *studiolight_create(int flag) { struct StudioLight *sl = MEM_callocN(sizeof(*sl), __func__); - sl->path[0] = 0x00; + sl->filepath[0] = 0x00; sl->name[0] = 0x00; sl->path_irr_cache = NULL; sl->path_sh_cache = NULL; @@ -201,7 +201,7 @@ static struct StudioLight *studiolight_create(int flag) static void studiolight_load_solid_light(StudioLight *sl) { - LinkNode *lines = BLI_file_read_as_lines(sl->path); + LinkNode *lines = BLI_file_read_as_lines(sl->filepath); if (lines) { READ_VEC3("light_ambient", sl->light_ambient, lines); READ_SOLIDLIGHT(sl->light, 0, lines); @@ -238,7 +238,7 @@ static void studiolight_load_solid_light(StudioLight *sl) static void studiolight_write_solid_light(StudioLight *sl) { - FILE *fp = BLI_fopen(sl->path, "wb"); + FILE *fp = BLI_fopen(sl->filepath, "wb"); if (fp) { DynStr *str = BLI_dynstr_new(); @@ -393,7 +393,7 @@ static void studiolight_multilayer_addpass(void *base, static void studiolight_load_equirect_image(StudioLight *sl) { if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { - ImBuf *ibuf = IMB_loadiffname(sl->path, IB_multilayer, NULL); + ImBuf *ibuf = IMB_loadiffname(sl->filepath, IB_multilayer, NULL); ImBuf *specular_ibuf = NULL; ImBuf *diffuse_ibuf = NULL; const bool failed = (ibuf == NULL); @@ -1151,24 +1151,24 @@ static void studiolight_calculate_irradiance_equirect_image(StudioLight *sl) sl->flag |= STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED; } -static StudioLight *studiolight_add_file(const char *path, int flag) +static StudioLight *studiolight_add_file(const char *filepath, int flag) { char filename[FILE_MAXFILE]; - BLI_path_split_file_part(path, filename, FILE_MAXFILE); + BLI_path_split_file_part(filepath, filename, FILE_MAXFILE); if ((((flag & STUDIOLIGHT_TYPE_STUDIO) != 0) && BLI_path_extension_check(filename, ".sl")) || BLI_path_extension_check_array(filename, imb_ext_image)) { StudioLight *sl = studiolight_create(STUDIOLIGHT_EXTERNAL_FILE | flag); BLI_strncpy(sl->name, filename, FILE_MAXFILE); - BLI_strncpy(sl->path, path, FILE_MAXFILE); + BLI_strncpy(sl->filepath, filepath, FILE_MAXFILE); if ((flag & STUDIOLIGHT_TYPE_STUDIO) != 0) { studiolight_load_solid_light(sl); } else { - sl->path_irr_cache = BLI_string_joinN(path, ".irr"); - sl->path_sh_cache = BLI_string_joinN(path, ".sh2"); + sl->path_irr_cache = BLI_string_joinN(filepath, ".irr"); + sl->path_sh_cache = BLI_string_joinN(filepath, ".sh2"); } BLI_addtail(&studiolights, sl); return sl; @@ -1578,13 +1578,13 @@ void BKE_studiolight_remove(StudioLight *sl) } } -StudioLight *BKE_studiolight_load(const char *path, int type) +StudioLight *BKE_studiolight_load(const char *filepath, int type) { - StudioLight *sl = studiolight_add_file(path, type | STUDIOLIGHT_USER_DEFINED); + StudioLight *sl = studiolight_add_file(filepath, type | STUDIOLIGHT_USER_DEFINED); return sl; } -StudioLight *BKE_studiolight_create(const char *path, +StudioLight *BKE_studiolight_create(const char *filepath, const SolidLight light[4], const float light_ambient[3]) { @@ -1593,8 +1593,8 @@ StudioLight *BKE_studiolight_create(const char *path, STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS); char filename[FILE_MAXFILE]; - BLI_path_split_file_part(path, filename, FILE_MAXFILE); - STRNCPY(sl->path, path); + BLI_path_split_file_part(filepath, filename, FILE_MAXFILE); + STRNCPY(sl->filepath, filepath); STRNCPY(sl->name, filename); memcpy(sl->light, light, sizeof(*light) * 4); diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 76f0cb99957..541f9acf9fb 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -140,11 +140,11 @@ bMovieHandle *BKE_movie_handle_get(const char imtype) #ifdef WITH_AVI -static void filepath_avi(char *string, const RenderData *rd, bool preview, const char *suffix) +static void filepath_avi(char *filepath, const RenderData *rd, bool preview, const char *suffix) { int sfra, efra; - if (string == NULL) { + if (filepath == NULL) { return; } @@ -157,24 +157,24 @@ static void filepath_avi(char *string, const RenderData *rd, bool preview, const efra = rd->efra; } - strcpy(string, rd->pic); - BLI_path_abs(string, BKE_main_blendfile_path_from_global()); + strcpy(filepath, rd->pic); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); - BLI_file_ensure_parent_dir_exists(string); + BLI_file_ensure_parent_dir_exists(filepath); if (rd->scemode & R_EXTENSION) { - if (!BLI_path_extension_check(string, ".avi")) { - BLI_path_frame_range(string, sfra, efra, 4); - BLI_strncat(string, ".avi", FILE_MAX); + if (!BLI_path_extension_check(filepath, ".avi")) { + BLI_path_frame_range(filepath, sfra, efra, 4); + BLI_strncat(filepath, ".avi", FILE_MAX); } } else { - if (BLI_path_frame_check_chars(string)) { - BLI_path_frame_range(string, sfra, efra, 4); + if (BLI_path_frame_check_chars(filepath)) { + BLI_path_frame_range(filepath, sfra, efra, 4); } } - BLI_path_suffix(string, FILE_MAX, suffix, ""); + BLI_path_suffix(filepath, FILE_MAX, suffix, ""); } static int start_avi(void *context_v, @@ -297,13 +297,13 @@ static void context_free_avi(void *context_v) #endif /* WITH_AVI */ -void BKE_movie_filepath_get(char *string, const RenderData *rd, bool preview, const char *suffix) +void BKE_movie_filepath_get(char *filepath, const RenderData *rd, bool preview, const char *suffix) { bMovieHandle *mh = BKE_movie_handle_get(rd->im_format.imtype); if (mh && mh->get_movie_path) { - mh->get_movie_path(string, rd, preview, suffix); + mh->get_movie_path(filepath, rd, preview, suffix); } else { - string[0] = '\0'; + filepath[0] = '\0'; } } diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 42bcfe10062..c107c028985 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1097,7 +1097,7 @@ static int start_ffmpeg_impl(FFMpegContext *context, /* Handle to the output file */ AVFormatContext *of; const AVOutputFormat *fmt; - char name[FILE_MAX], error[1024]; + char filepath[FILE_MAX], error[1024]; const char **exts; context->ffmpeg_type = rd->ffcodecdata.type; @@ -1115,14 +1115,14 @@ static int start_ffmpeg_impl(FFMpegContext *context, } /* Determine the correct filename */ - ffmpeg_filepath_get(context, name, rd, context->ffmpeg_preview, suffix); + ffmpeg_filepath_get(context, filepath, rd, context->ffmpeg_preview, suffix); PRINT( "Starting output to %s(ffmpeg)...\n" " Using type=%d, codec=%d, audio_codec=%d,\n" " video_bitrate=%d, audio_bitrate=%d,\n" " gop_size=%d, autosplit=%d\n" " render width=%d, render height=%d\n", - name, + filepath, context->ffmpeg_type, context->ffmpeg_codec, context->ffmpeg_audio_codec, @@ -1155,7 +1155,7 @@ static int start_ffmpeg_impl(FFMpegContext *context, enum AVCodecID audio_codec = context->ffmpeg_audio_codec; enum AVCodecID video_codec = context->ffmpeg_codec; - of->url = av_strdup(name); + of->url = av_strdup(filepath); /* Check if we need to force change the codec because of file type codec restrictions */ switch (context->ffmpeg_type) { case FFMPEG_OGG: @@ -1256,7 +1256,7 @@ static int start_ffmpeg_impl(FFMpegContext *context, } } if (!(fmt->flags & AVFMT_NOFILE)) { - if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) { + if (avio_open(&of->pb, filepath, AVIO_FLAG_WRITE) < 0) { BKE_report(reports, RPT_ERROR, "Could not open file for writing"); PRINT("Could not open file for writing\n"); goto fail; @@ -1278,7 +1278,7 @@ static int start_ffmpeg_impl(FFMpegContext *context, } context->outfile = of; - av_dump_format(of, 0, name, 1); + av_dump_format(of, 0, filepath, 1); return 1; @@ -1426,9 +1426,12 @@ static void ffmpeg_filepath_get(FFMpegContext *context, BLI_path_suffix(string, FILE_MAX, suffix, ""); } -void BKE_ffmpeg_filepath_get(char *string, const RenderData *rd, bool preview, const char *suffix) +void BKE_ffmpeg_filepath_get(char *filepath, + const RenderData *rd, + bool preview, + const char *suffix) { - ffmpeg_filepath_get(NULL, string, rd, preview, suffix); + ffmpeg_filepath_get(NULL, filepath, rd, preview, suffix); } int BKE_ffmpeg_start(void *context_v, diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index 2aa27973fb7..2defe7853be 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -49,14 +49,14 @@ int BLI_rename(const char *from, const char *to) ATTR_NONNULL(); * * \return zero on success (matching 'remove' behavior). */ -int BLI_delete(const char *file, bool dir, bool recursive) ATTR_NONNULL(); +int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL(); /** * Soft deletes the specified file or directory (depending on dir) by moving the files to the * recycling bin, optionally doing recursive delete of directory contents. * * \return zero on success (matching 'remove' behavior). */ -int BLI_delete_soft(const char *file, const char **error_message) ATTR_NONNULL(); +int BLI_delete_soft(const char *filepath, const char **error_message) ATTR_NONNULL(); /** * When `path` points to a directory, moves all its contents into `to`, * else rename `path` itself to `to`. @@ -276,7 +276,7 @@ bool BLI_file_is_writable(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NON * Creates the file with nothing in it, or updates its last-modified date if it already exists. * Returns true if successful (like the unix touch command). */ -bool BLI_file_touch(const char *file) ATTR_NONNULL(1); +bool BLI_file_touch(const char *filepath) ATTR_NONNULL(1); /** * Ensures that the parent directory of `filepath` exists. * diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index bdc75054f92..0e3240e4b29 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -242,12 +242,13 @@ void BLI_path_slash_rstrip(char *string) ATTR_NONNULL(1); void BLI_path_slash_native(char *path) ATTR_NONNULL(1); #ifdef _WIN32 -bool BLI_path_program_extensions_add_win32(char *name, size_t maxlen); +bool BLI_path_program_extensions_add_win32(char *program_name, size_t maxlen); #endif /** * Search for a binary (executable) */ -bool BLI_path_program_search(char *fullname, size_t maxlen, const char *name) ATTR_NONNULL(1, 3); +bool BLI_path_program_search(char *program_filepath, size_t maxlen, const char *program_name) + ATTR_NONNULL(1, 3); /** * \return true when `str` end with `ext` (case insensitive). diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index e196d50813e..a6d494bf5a9 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -257,9 +257,9 @@ bool BLI_file_is_writable(const char *filepath) return writable; } -bool BLI_file_touch(const char *file) +bool BLI_file_touch(const char *filepath) { - FILE *f = BLI_fopen(file, "r+b"); + FILE *f = BLI_fopen(filepath, "r+b"); if (f != NULL) { int c = getc(f); @@ -267,7 +267,7 @@ bool BLI_file_touch(const char *file) if (c == EOF) { /* Empty file, reopen in truncate write mode... */ fclose(f); - f = BLI_fopen(file, "w+b"); + f = BLI_fopen(filepath, "w+b"); } else { /* Otherwise, rewrite first byte. */ @@ -276,7 +276,7 @@ bool BLI_file_touch(const char *file) } } else { - f = BLI_fopen(file, "wb"); + f = BLI_fopen(filepath, "wb"); } if (f) { fclose(f); @@ -468,9 +468,9 @@ static bool delete_recursive(const char *dir) i = filelist_num = BLI_filelist_dir_contents(dir, &filelist); fl = filelist; while (i--) { - const char *file = BLI_path_basename(fl->path); + const char *filename = BLI_path_basename(fl->path); - if (FILENAME_IS_CURRPAR(file)) { + if (FILENAME_IS_CURRPAR(filename)) { /* Skip! */ } else if (S_ISDIR(fl->type)) { @@ -501,17 +501,17 @@ static bool delete_recursive(const char *dir) return err; } -int BLI_delete(const char *file, bool dir, bool recursive) +int BLI_delete(const char *path, bool dir, bool recursive) { int err; - BLI_assert(!BLI_path_is_rel(file)); + BLI_assert(!BLI_path_is_rel(path)); if (recursive) { - err = delete_recursive(file); + err = delete_recursive(path); } else { - err = delete_unique(file, dir); + err = delete_unique(path, dir); } return err; @@ -1006,17 +1006,17 @@ int BLI_access(const char *filepath, int mode) return access(filepath, mode); } -int BLI_delete(const char *file, bool dir, bool recursive) +int BLI_delete(const char *path, bool dir, bool recursive) { - BLI_assert(!BLI_path_is_rel(file)); + BLI_assert(!BLI_path_is_rel(path)); if (recursive) { - return recursive_operation(file, NULL, NULL, delete_single_file, delete_callback_post); + return recursive_operation(path, NULL, NULL, delete_single_file, delete_callback_post); } if (dir) { - return rmdir(file); + return rmdir(path); } - return remove(file); + return remove(path); } int BLI_delete_soft(const char *file, const char **error_message) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 17bb5bc2aef..f07cb901fa8 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -42,7 +42,7 @@ static int BLI_path_unc_prefix_len(const char *path); #ifdef WIN32 -static bool BLI_path_is_abs_win32(const char *name); +static bool BLI_path_is_abs_win32(const char *path); #endif /* WIN32 */ // #define DEBUG_STRSIZE @@ -485,9 +485,9 @@ bool BLI_path_is_rel(const char *path) return path[0] == '/' && path[1] == '/'; } -bool BLI_path_is_unc(const char *name) +bool BLI_path_is_unc(const char *path) { - return name[0] == '\\' && name[1] == '\\'; + return path[0] == '\\' && path[1] == '\\'; } /** @@ -520,9 +520,9 @@ static int BLI_path_unc_prefix_len(const char *path) * \note Not to be confused with the opposite of #BLI_path_is_rel which checks for the * Blender specific convention of using `//` prefix for blend-file relative paths. */ -static bool BLI_path_is_abs_win32(const char *name) +static bool BLI_path_is_abs_win32(const char *path) { - return (name[1] == ':' && ELEM(name[2], '\\', '/')) || BLI_path_is_unc(name); + return (path[1] == ':' && ELEM(path[2], '\\', '/')) || BLI_path_is_unc(path); } static wchar_t *next_slash(wchar_t *path) @@ -1140,7 +1140,7 @@ bool BLI_path_abs_from_cwd(char *path, const size_t maxlen) * environment variable (Windows-only) onto `name` in turn until such a file is found. * Returns success/failure. */ -bool BLI_path_program_extensions_add_win32(char *name, const size_t maxlen) +bool BLI_path_program_extensions_add_win32(char *program_name, const size_t maxlen) { bool retval = false; int type; @@ -1187,10 +1187,10 @@ bool BLI_path_program_extensions_add_win32(char *name, const size_t maxlen) } #endif /* WIN32 */ -bool BLI_path_program_search(char *fullname, const size_t maxlen, const char *name) +bool BLI_path_program_search(char *program_filepath, const size_t maxlen, const char *program_name) { #ifdef DEBUG_STRSIZE - memset(fullname, 0xff, sizeof(*fullname) * maxlen); + memset(program_filepath, 0xff, sizeof(*program_filepath) * maxlen); #endif const char *path; bool retval = false; @@ -1217,7 +1217,7 @@ bool BLI_path_program_search(char *fullname, const size_t maxlen, const char *na BLI_strncpy(filepath_test, path, sizeof(filepath_test)); } - BLI_path_append(filepath_test, maxlen, name); + BLI_path_append(filepath_test, maxlen, program_name); if ( #ifdef _WIN32 BLI_path_program_extensions_add_win32(filepath_test, maxlen) @@ -1226,7 +1226,7 @@ bool BLI_path_program_search(char *fullname, const size_t maxlen, const char *na #endif ) { - BLI_strncpy(fullname, filepath_test, maxlen); + BLI_strncpy(program_filepath, filepath_test, maxlen); retval = true; break; } @@ -1234,7 +1234,7 @@ bool BLI_path_program_search(char *fullname, const size_t maxlen, const char *na } if (retval == false) { - *fullname = '\0'; + *program_filepath = '\0'; } return retval; diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 1cabccbbed4..7b2f0d049bb 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -136,7 +136,7 @@ double BLI_dir_free_space(const char *dir) struct statfs disk; # endif - char name[FILE_MAXDIR], *slash; + char dirname[FILE_MAXDIR], *slash; int len = strlen(dir); if (len >= FILE_MAXDIR) { @@ -144,28 +144,28 @@ double BLI_dir_free_space(const char *dir) return -1; } - strcpy(name, dir); + strcpy(dirname, dir); if (len) { - slash = strrchr(name, '/'); + slash = strrchr(dirname, '/'); if (slash) { slash[1] = 0; } } else { - strcpy(name, "/"); + strcpy(dirname, "/"); } # if defined(USE_STATFS_STATVFS) - if (statvfs(name, &disk)) { + if (statvfs(dirname, &disk)) { return -1; } # elif defined(USE_STATFS_4ARGS) - if (statfs(name, &disk, sizeof(struct statfs), 0)) { + if (statfs(dirname, &disk, sizeof(struct statfs), 0)) { return -1; } # else - if (statfs(name, &disk)) { + if (statfs(dirname, &disk)) { return -1; } # endif diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 53bc72cdfd6..040efa2c214 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -515,20 +515,20 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab ListBase *mainlist = fd->mainlist; Main *m; Library *lib; - char name1[FILE_MAX]; + char filepath_abs[FILE_MAX]; - BLI_strncpy(name1, filepath, sizeof(name1)); - BLI_path_abs(name1, relabase); - BLI_path_normalize(name1); + BLI_strncpy(filepath_abs, filepath, sizeof(filepath_abs)); + BLI_path_abs(filepath_abs, relabase); + BLI_path_normalize(filepath_abs); // printf("blo_find_main: relabase %s\n", relabase); // printf("blo_find_main: original in %s\n", filepath); - // printf("blo_find_main: converted to %s\n", name1); + // printf("blo_find_main: converted to %s\n", filepath_abs); for (m = static_cast
(mainlist->first); m; m = m->next) { const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->filepath; - if (BLI_path_cmp(name1, libname) == 0) { + if (BLI_path_cmp(filepath_abs, libname) == 0) { if (G.debug & G_DEBUG) { CLOG_INFO(&LOG, 3, "Found library %s", libname); } @@ -551,7 +551,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab id_us_ensure_real(&lib->id); BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath)); - BLI_strncpy(lib->filepath_abs, name1, sizeof(lib->filepath_abs)); + BLI_strncpy(lib->filepath_abs, filepath_abs, sizeof(lib->filepath_abs)); m->curlib = lib; diff --git a/source/blender/compositor/intern/COM_Debug.cc b/source/blender/compositor/intern/COM_Debug.cc index da2bef224a4..ebe9b7fe2ea 100644 --- a/source/blender/compositor/intern/COM_Debug.cc +++ b/source/blender/compositor/intern/COM_Debug.cc @@ -457,9 +457,9 @@ void DebugInfo::export_operation(const NodeOperation *op, MemoryBuffer *render) const std::string file_name = operation_class_name(op) + "_" + std::to_string(op->get_id()) + ".png"; - const std::string path = get_operations_export_dir() + file_name; - BLI_file_ensure_parent_dir_exists(path.c_str()); - IMB_saveiff(ibuf, path.c_str(), ibuf->flags); + const std::string filepath = get_operations_export_dir() + file_name; + BLI_file_ensure_parent_dir_exists(filepath.c_str()); + IMB_saveiff(ibuf, filepath.c_str(), ibuf->flags); IMB_freeImBuf(ibuf); } diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc index 3cb8f6d99b8..f427b194f08 100644 --- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc +++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc @@ -32,7 +32,7 @@ OutputOpenExrSingleLayerMultiViewOperation::OutputOpenExrSingleLayerMultiViewOpe { } -void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filename) +void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filepath) { size_t width = this->get_width(); size_t height = this->get_height(); @@ -41,7 +41,7 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam if (width != 0 && height != 0) { void *exrhandle; - exrhandle = IMB_exr_get_handle_name(filename); + exrhandle = IMB_exr_get_handle_name(filepath); if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) { return exrhandle; @@ -58,11 +58,11 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam add_exr_channels(exrhandle, nullptr, datatype_, srv->name, width, false, nullptr); } - BLI_file_ensure_parent_dir_exists(filename); + BLI_file_ensure_parent_dir_exists(filepath); /* prepare the file with all the channels */ - if (!IMB_exr_begin_write(exrhandle, filename, width, height, format_.exr_codec, nullptr)) { + if (!IMB_exr_begin_write(exrhandle, filepath, width, height, format_.exr_codec, nullptr)) { printf("Error Writing Singlelayer Multiview Openexr\n"); IMB_exr_close(exrhandle); } @@ -81,9 +81,9 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinit_execution() if (width != 0 && height != 0) { void *exrhandle; - char filename[FILE_MAX]; + char filepath[FILE_MAX]; - BKE_image_path_from_imtype(filename, + BKE_image_path_from_imtype(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -92,7 +92,7 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinit_execution() true, nullptr); - exrhandle = this->get_handle(filename); + exrhandle = this->get_handle(filepath); add_exr_channels(exrhandle, nullptr, datatype_, @@ -132,7 +132,7 @@ OutputOpenExrMultiLayerMultiViewOperation::OutputOpenExrMultiLayerMultiViewOpera { } -void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename) +void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filepath) { uint width = this->get_width(); uint height = this->get_height(); @@ -143,7 +143,7 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename SceneRenderView *srv; /* get a new global handle */ - exrhandle = IMB_exr_get_handle_name(filename); + exrhandle = IMB_exr_get_handle_name(filepath); if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) { return exrhandle; @@ -171,11 +171,11 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename } } - BLI_file_ensure_parent_dir_exists(filename); + BLI_file_ensure_parent_dir_exists(filepath); /* prepare the file with all the channels for the header */ StampData *stamp_data = create_stamp_data(); - if (!IMB_exr_begin_write(exrhandle, filename, width, height, exr_codec_, stamp_data)) { + if (!IMB_exr_begin_write(exrhandle, filepath, width, height, exr_codec_, stamp_data)) { printf("Error Writing Multilayer Multiview Openexr\n"); IMB_exr_close(exrhandle); BKE_stamp_data_free(stamp_data); @@ -196,9 +196,9 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinit_execution() if (width != 0 && height != 0) { void *exrhandle; - char filename[FILE_MAX]; + char filepath[FILE_MAX]; - BKE_image_path_from_imtype(filename, + BKE_image_path_from_imtype(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -207,7 +207,7 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinit_execution() true, nullptr); - exrhandle = this->get_handle(filename); + exrhandle = this->get_handle(filepath); for (uint i = 0; i < layers_.size(); i++) { add_exr_channels(exrhandle, @@ -247,17 +247,17 @@ OutputStereoOperation::OutputStereoOperation(const Scene *scene, DataType datatype, const ImageFormatData *format, const char *path, - const char *name, + const char *pass_name, const char *view_name, const bool save_as_render) : OutputSingleLayerOperation( scene, rd, tree, datatype, format, path, view_name, save_as_render) { - BLI_strncpy(name_, name, sizeof(name_)); + BLI_strncpy(pass_name_, pass_name, sizeof(pass_name_)); channels_ = get_datatype_size(datatype); } -void *OutputStereoOperation::get_handle(const char *filename) +void *OutputStereoOperation::get_handle(const char *filepath) { size_t width = this->get_width(); size_t height = this->get_height(); @@ -267,7 +267,7 @@ void *OutputStereoOperation::get_handle(const char *filename) if (width != 0 && height != 0) { void *exrhandle; - exrhandle = IMB_exr_get_handle_name(filename); + exrhandle = IMB_exr_get_handle_name(filepath); if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) { return exrhandle; @@ -298,7 +298,7 @@ void OutputStereoOperation::deinit_execution() /* populate single EXR channel with view data */ IMB_exr_add_channel(exrhandle, nullptr, - name_, + pass_name_, view_name_, 1, channels_ * width * height, @@ -312,12 +312,12 @@ void OutputStereoOperation::deinit_execution() if (BKE_scene_multiview_is_render_view_last(rd_, view_name_)) { ImBuf *ibuf[3] = {nullptr}; const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; - char filename[FILE_MAX]; + char filepath[FILE_MAX]; int i; /* get rectf from EXR */ for (i = 0; i < 2; i++) { - float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, name_, names[i]); + float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, pass_name_, names[i]); ibuf[i] = IMB_allocImBuf(width, height, format_.planes, 0); ibuf[i]->channels = channels_; @@ -332,7 +332,7 @@ void OutputStereoOperation::deinit_execution() /* create stereo buffer */ ibuf[2] = IMB_stereo3d_ImBuf(&format_, ibuf[0], ibuf[1]); - BKE_image_path_from_imformat(filename, + BKE_image_path_from_imformat(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -341,7 +341,7 @@ void OutputStereoOperation::deinit_execution() true, nullptr); - BKE_imbuf_write(ibuf[2], filename, &format_); + BKE_imbuf_write(ibuf[2], filepath, &format_); /* imbuf knows which rects are not part of ibuf */ for (i = 0; i < 3; i++) { diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h index 70773c1a559..4fe225f319b 100644 --- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h @@ -27,7 +27,7 @@ class OutputOpenExrSingleLayerMultiViewOperation : public OutputSingleLayerOpera const char *view_name, bool save_as_render); - void *get_handle(const char *filename); + void *get_handle(const char *filepath); void deinit_execution() override; }; @@ -43,13 +43,14 @@ class OutputOpenExrMultiLayerMultiViewOperation : public OutputOpenExrMultiLayer bool exr_half_float, const char *view_name); - void *get_handle(const char *filename); + void *get_handle(const char *filepath); void deinit_execution() override; }; class OutputStereoOperation : public OutputSingleLayerOperation { private: - char name_[FILE_MAX]; + /* NOTE: Using FILE_MAX here is misleading, this is not a file path. */ + char pass_name_[FILE_MAX]; size_t channels_; public: @@ -59,10 +60,10 @@ class OutputStereoOperation : public OutputSingleLayerOperation { DataType datatype, const struct ImageFormatData *format, const char *path, - const char *name, + const char *pass_name, const char *view_name, bool save_as_render); - void *get_handle(const char *filename); + void *get_handle(const char *filepath); void deinit_execution() override; }; diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cc b/source/blender/compositor/operations/COM_OutputFileOperation.cc index d2c6cb13ade..22a8ef7381b 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cc +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cc @@ -253,7 +253,7 @@ void OutputSingleLayerOperation::deinit_execution() int size = get_datatype_size(datatype_); ImBuf *ibuf = IMB_allocImBuf(this->get_width(), this->get_height(), format_.planes, 0); - char filename[FILE_MAX]; + char filepath[FILE_MAX]; const char *suffix; ibuf->channels = size; @@ -265,7 +265,7 @@ void OutputSingleLayerOperation::deinit_execution() suffix = BKE_scene_multiview_view_suffix_get(rd_, view_name_); - BKE_image_path_from_imformat(filename, + BKE_image_path_from_imformat(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -274,11 +274,11 @@ void OutputSingleLayerOperation::deinit_execution() true, suffix); - if (0 == BKE_imbuf_write(ibuf, filename, &format_)) { - printf("Cannot save Node File Output to %s\n", filename); + if (0 == BKE_imbuf_write(ibuf, filepath, &format_)) { + printf("Cannot save Node File Output to %s\n", filepath); } else { - printf("Saved: %s\n", filename); + printf("Saved: %s\n", filepath); } IMB_freeImBuf(ibuf); @@ -395,12 +395,12 @@ void OutputOpenExrMultiLayerOperation::deinit_execution() uint width = this->get_width(); uint height = this->get_height(); if (width != 0 && height != 0) { - char filename[FILE_MAX]; + char filepath[FILE_MAX]; const char *suffix; void *exrhandle = IMB_exr_get_handle(); suffix = BKE_scene_multiview_view_suffix_get(rd_, view_name_); - BKE_image_path_from_imtype(filename, + BKE_image_path_from_imtype(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -408,7 +408,7 @@ void OutputOpenExrMultiLayerOperation::deinit_execution() (rd_->scemode & R_EXTENSION) != 0, true, suffix); - BLI_file_ensure_parent_dir_exists(filename); + BLI_file_ensure_parent_dir_exists(filepath); for (uint i = 0; i < layers_.size(); i++) { OutputOpenExrLayer &layer = layers_[i]; @@ -425,9 +425,9 @@ void OutputOpenExrMultiLayerOperation::deinit_execution() layers_[i].output_buffer); } - /* when the filename has no permissions, this can fail */ + /* When the filepath has no permissions, this can fail. */ StampData *stamp_data = create_stamp_data(); - if (IMB_exr_begin_write(exrhandle, filename, width, height, exr_codec_, stamp_data)) { + if (IMB_exr_begin_write(exrhandle, filepath, width, height, exr_codec_, stamp_data)) { IMB_exr_write_channels(exrhandle); } else { diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index 774c2507961..1c2f182ae20 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -874,9 +874,9 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, BakeImage *bk_image = &targets->images[i]; BakeData *bake = &bkr->scene->r.bake; - char name[FILE_MAX]; + char filepath[FILE_MAX]; - BKE_image_path_from_imtype(name, + BKE_image_path_from_imtype(filepath, bkr->filepath, BKE_main_blendfile_path(bkr->main), 0, @@ -886,33 +886,33 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, nullptr); if (bkr->is_automatic_name) { - BLI_path_suffix(name, FILE_MAX, ob->id.name + 2, "_"); - BLI_path_suffix(name, FILE_MAX, bkr->identifier, "_"); + BLI_path_suffix(filepath, FILE_MAX, ob->id.name + 2, "_"); + BLI_path_suffix(filepath, FILE_MAX, bkr->identifier, "_"); } if (bkr->is_split_materials) { if (ob_eval->mat[i]) { - BLI_path_suffix(name, FILE_MAX, ob_eval->mat[i]->id.name + 2, "_"); + BLI_path_suffix(filepath, FILE_MAX, ob_eval->mat[i]->id.name + 2, "_"); } else if (mesh_eval->mat[i]) { - BLI_path_suffix(name, FILE_MAX, mesh_eval->mat[i]->id.name + 2, "_"); + BLI_path_suffix(filepath, FILE_MAX, mesh_eval->mat[i]->id.name + 2, "_"); } else { /* if everything else fails, use the material index */ char tmp[5]; BLI_snprintf(tmp, sizeof(tmp), "%d", i % 1000); - BLI_path_suffix(name, FILE_MAX, tmp, "_"); + BLI_path_suffix(filepath, FILE_MAX, tmp, "_"); } } if (bk_image->tile_number) { char tmp[FILE_MAX]; SNPRINTF(tmp, "%d", bk_image->tile_number); - BLI_path_suffix(name, FILE_MAX, tmp, "_"); + BLI_path_suffix(filepath, FILE_MAX, tmp, "_"); } /* save it externally */ - const bool ok = write_external_bake_pixels(name, + const bool ok = write_external_bake_pixels(filepath, pixel_array + bk_image->offset, targets->result + bk_image->offset * targets->channels_num, @@ -927,11 +927,11 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, bk_image->uv_offset); if (!ok) { - BKE_reportf(reports, RPT_ERROR, "Problem saving baked map in \"%s\"", name); + BKE_reportf(reports, RPT_ERROR, "Problem saving baked map in \"%s\"", filepath); all_ok = false; } else { - BKE_reportf(reports, RPT_INFO, "Baking map written to \"%s\"", name); + BKE_reportf(reports, RPT_INFO, "Baking map written to \"%s\"", filepath); } if (!bkr->is_split_materials) { diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index e1582bf23f4..0daee0b2c90 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -422,11 +422,11 @@ static void screen_opengl_render_write(OGLRender *oglrender) Scene *scene = oglrender->scene; RenderResult *rr; bool ok; - char name[FILE_MAX]; + char filepath[FILE_MAX]; rr = RE_AcquireResultRead(oglrender->re); - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), scene->r.cfra, @@ -437,15 +437,15 @@ static void screen_opengl_render_write(OGLRender *oglrender) /* write images as individual images or stereo */ BKE_render_result_stamp_info(scene, scene->camera, rr, false); - ok = BKE_image_render_write(oglrender->reports, rr, scene, false, name); + ok = BKE_image_render_write(oglrender->reports, rr, scene, false, filepath); RE_ReleaseResultImage(oglrender->re); if (ok) { - printf("OpenGL Render written to '%s'\n", name); + printf("OpenGL Render written to '%s'\n", filepath); } else { - printf("OpenGL Render failed to write '%s'\n", name); + printf("OpenGL Render failed to write '%s'\n", filepath); } } @@ -1064,8 +1064,8 @@ static void write_result(TaskPool *__restrict pool, WriteTaskData *task_data) /* TODO(sergey): We can in theory save some CPU ticks here because we * calculate file name again here. */ - char name[FILE_MAX]; - BKE_image_path_from_imformat(name, + char filepath[FILE_MAX]; + BKE_image_path_from_imformat(filepath, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), cfra, @@ -1075,9 +1075,9 @@ static void write_result(TaskPool *__restrict pool, WriteTaskData *task_data) nullptr); BKE_render_result_stamp_info(scene, scene->camera, rr, false); - ok = BKE_image_render_write(nullptr, rr, scene, true, name); + ok = BKE_image_render_write(nullptr, rr, scene, true, filepath); if (!ok) { - BKE_reportf(&reports, RPT_ERROR, "Write error: cannot save %s", name); + BKE_reportf(&reports, RPT_ERROR, "Write error: cannot save %s", filepath); } } if (reports.list.first != nullptr) { @@ -1133,7 +1133,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) OGLRender *oglrender = static_cast(op->customdata); Scene *scene = oglrender->scene; Depsgraph *depsgraph = oglrender->depsgraph; - char name[FILE_MAX]; + char filepath[FILE_MAX]; bool ok = false; const bool view_context = (oglrender->v3d != nullptr); bool is_movie; @@ -1151,7 +1151,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) is_movie = BKE_imtype_is_movie(scene->r.im_format.imtype); if (!is_movie) { - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), scene->r.cfra, @@ -1160,9 +1160,9 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) true, nullptr); - if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) { + if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(filepath)) { BLI_spin_lock(&oglrender->reports_lock); - BKE_reportf(op->reports, RPT_INFO, "Skipping existing frame \"%s\"", name); + BKE_reportf(op->reports, RPT_INFO, "Skipping existing frame \"%s\"", filepath); BLI_spin_unlock(&oglrender->reports_lock); ok = true; goto finally; diff --git a/source/blender/editors/space_file/file_draw.cc b/source/blender/editors/space_file/file_draw.cc index d7ccf12f888..1202959b125 100644 --- a/source/blender/editors/space_file/file_draw.cc +++ b/source/blender/editors/space_file/file_draw.cc @@ -217,7 +217,7 @@ static void file_draw_string(int sx, { uiFontStyle fs; rcti rect; - char fname[FILE_MAXFILE]; + char filename[FILE_MAXFILE]; if (string[0] == '\0' || width < 1) { return; @@ -226,8 +226,8 @@ static void file_draw_string(int sx, const uiStyle *style = UI_style_get(); fs = style->widget; - BLI_strncpy(fname, string, FILE_MAXFILE); - UI_text_clip_middle_ex(&fs, fname, width, UI_ICON_SIZE, sizeof(fname), '\0'); + BLI_strncpy(filename, string, FILE_MAXFILE); + UI_text_clip_middle_ex(&fs, filename, width, UI_ICON_SIZE, sizeof(filename), '\0'); /* no text clipping needed, UI_fontstyle_draw does it but is a bit too strict * (for buttons it works) */ @@ -239,7 +239,7 @@ static void file_draw_string(int sx, uiFontStyleDraw_Params font_style_params{}; font_style_params.align = align; - UI_fontstyle_draw(&fs, &rect, fname, sizeof(fname), col, &font_style_params); + UI_fontstyle_draw(&fs, &rect, filename, sizeof(filename), col, &font_style_params); } /** diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index a15ec2ca941..cd7de03292e 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2583,24 +2583,26 @@ void FILE_OT_filepath_drop(wmOperatorType *ot) * \{ */ /** - * Create a new, non-existing folder name, returns true if successful, + * Create a new, non-existing folder `dirname`, returns true if successful, * false if name couldn't be created. - * The actual name is returned in 'name', 'folder' contains the complete path, + * The actual name is returned in `r_dirpath`, `r_dirpath_full` contains the complete path, * including the new folder name. */ -static bool new_folder_path(const char *parent, char folder[FILE_MAX], char name[FILE_MAXFILE]) +static bool new_folder_path(const char *parent, + char r_dirpath_full[FILE_MAX], + char r_dirname[FILE_MAXFILE]) { int i = 1; int len = 0; - BLI_strncpy(name, "New Folder", FILE_MAXFILE); - BLI_path_join(folder, FILE_MAX, parent, name); - /* check whether folder with the name already exists, in this case + BLI_strncpy(r_dirname, "New Folder", FILE_MAXFILE); + BLI_path_join(r_dirpath_full, FILE_MAX, parent, r_dirname); + /* check whether r_dirpath_full 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_path_join(folder, FILE_MAX, parent, name); + while (BLI_exists(r_dirpath_full) && (len < FILE_MAXFILE)) { + len = BLI_snprintf(r_dirname, FILE_MAXFILE, "New Folder(%d)", i); + BLI_path_join(r_dirpath_full, FILE_MAX, parent, r_dirname); i++; } @@ -2609,7 +2611,7 @@ static bool new_folder_path(const char *parent, char folder[FILE_MAX], char name static int file_directory_new_exec(bContext *C, wmOperator *op) { - char name[FILE_MAXFILE]; + char dirname[FILE_MAXFILE]; char path[FILE_MAX]; bool generate_name = true; @@ -2635,7 +2637,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op) if (generate_name) { /* create a new, non-existing folder name */ - if (!new_folder_path(params->dir, path, name)) { + if (!new_folder_path(params->dir, path, dirname)) { BKE_report(op->reports, RPT_ERROR, "Could not create new folder name"); return OPERATOR_CANCELLED; } @@ -2674,7 +2676,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op) BLI_assert_msg(params->rename_id == NULL, "File rename handling should immediately clear rename_id when done, " "because otherwise it will keep taking precedence over renamefile."); - BLI_strncpy(params->renamefile, name, FILE_MAXFILE); + BLI_strncpy(params->renamefile, dirname, FILE_MAXFILE); rename_flag = FILE_PARAMS_RENAME_PENDING; } @@ -2979,16 +2981,17 @@ static bool file_filenum_poll(bContext *C) } /** - * Looks for a string of digits within name (using BLI_path_sequence_decode) and adjusts it by add. + * Looks for a string of digits within filename (using BLI_path_sequence_decode) and adjusts it by + * add. */ -static void filenum_newname(char *name, size_t name_size, int add) +static void filenum_newname(char *filename, size_t filename_size, int add) { char head[FILE_MAXFILE], tail[FILE_MAXFILE]; - char name_temp[FILE_MAXFILE]; + char filename_temp[FILE_MAXFILE]; int pic; ushort digits; - pic = BLI_path_sequence_decode(name, head, sizeof(head), tail, sizeof(tail), &digits); + pic = BLI_path_sequence_decode(filename, head, sizeof(head), tail, sizeof(tail), &digits); /* are we going from 100 -> 99 or from 10 -> 9 */ if (add < 0 && digits > 0) { @@ -3006,8 +3009,8 @@ static void filenum_newname(char *name, size_t name_size, int add) if (pic < 0) { pic = 0; } - BLI_path_sequence_encode(name_temp, sizeof(name_temp), head, tail, digits, pic); - BLI_strncpy(name, name_temp, name_size); + BLI_path_sequence_encode(filename_temp, sizeof(filename_temp), head, tail, digits, pic); + BLI_strncpy(filename, filename_temp, filename_size); } static int file_filenum_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_file/filesel.cc b/source/blender/editors/space_file/filesel.cc index ca058c78e0b..d9feb3e7267 100644 --- a/source/blender/editors/space_file/filesel.cc +++ b/source/blender/editors/space_file/filesel.cc @@ -180,15 +180,15 @@ static FileSelectParams *fileselect_ensure_updated_file_params(SpaceFile *sfile) } if (is_filepath && RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) { - char name[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", name); + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); if (params->type == FILE_LOADLIB) { - BLI_strncpy(params->dir, name, sizeof(params->dir)); + BLI_strncpy(params->dir, filepath, sizeof(params->dir)); params->file[0] = '\0'; } else { BLI_path_split_dir_file( - name, params->dir, sizeof(params->dir), params->file, sizeof(params->file)); + filepath, params->dir, sizeof(params->dir), params->file, sizeof(params->file)); } } else { diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 51b92c37592..823777b66ed 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -829,11 +829,11 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX); /* Get name of the volume. */ - char name[FILE_MAXFILE] = ""; + char display_name[FILE_MAXFILE] = ""; CFStringRef nameString = NULL; CFURLCopyResourcePropertyForKey(cfURL, kCFURLVolumeLocalizedNameKey, &nameString, NULL); if (nameString != NULL) { - CFStringGetCString(nameString, name, sizeof(name), kCFStringEncodingUTF8); + CFStringGetCString(nameString, display_name, sizeof(display_name), kCFStringEncodingUTF8); CFRelease(nameString); } @@ -858,8 +858,12 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) CFRelease(localKey); } - fsmenu_insert_entry( - fsmenu, FS_CATEGORY_SYSTEM, defPath, name[0] ? name : NULL, icon, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, + FS_CATEGORY_SYSTEM, + defPath, + display_name[0] ? display_name : NULL, + icon, + FS_INSERT_SORTED); } CFRelease(volEnum); @@ -987,9 +991,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) const char *const xdg_runtime_dir = BLI_getenv("XDG_RUNTIME_DIR"); if (xdg_runtime_dir != NULL) { struct direntry *dirs; - char name[FILE_MAX]; - BLI_path_join(name, sizeof(name), xdg_runtime_dir, "gvfs/"); - const uint dirs_num = BLI_filelist_dir_contents(name, &dirs); + char filepath[FILE_MAX]; + BLI_path_join(filepath, sizeof(filepath), xdg_runtime_dir, "gvfs/"); + const uint dirs_num = BLI_filelist_dir_contents(filepath, &dirs); for (uint i = 0; i < dirs_num; i++) { if (dirs[i].type & S_IFDIR) { const char *dirname = dirs[i].relname; @@ -1003,7 +1007,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) const char *label_test = label + 6; label = *label_test ? label_test : dirname; } - BLI_snprintf(line, sizeof(line), "%s%s", name, dirname); + BLI_snprintf(line, sizeof(line), "%s%s", filepath, dirname); fsmenu_insert_entry( fsmenu, FS_CATEGORY_SYSTEM, line, label, ICON_NETWORK_DRIVE, FS_INSERT_SORTED); found = 1; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 5ad31740b48..29f6adbfbb5 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -1119,8 +1119,8 @@ void ED_file_read_bookmarks(void) fsmenu_read_system(ED_fsmenu_get(), true); if (cfgdir) { - char name[FILE_MAX]; - BLI_path_join(name, sizeof(name), cfgdir, BLENDER_BOOKMARK_FILE); - fsmenu_read_bookmarks(ED_fsmenu_get(), name); + char filepath[FILE_MAX]; + BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_BOOKMARK_FILE); + fsmenu_read_bookmarks(ED_fsmenu_get(), filepath); } } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index aea180bb64e..0fe4b13ebef 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -1253,8 +1253,8 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i } else if (ima->source == IMA_SRC_SEQUENCE && ibuf) { /* Image sequence frame number + filename */ - const char *filename = BLI_path_slash_rfind(ibuf->name); - filename = (filename == NULL) ? ibuf->name : filename + 1; + const char *filename = BLI_path_slash_rfind(ibuf->filepath); + filename = (filename == NULL) ? ibuf->filepath : filename + 1; BLI_snprintf(str, MAX_IMAGE_INFO_LEN, TIP_("Frame %d: %s"), framenr, filename); } else { diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 61b75540d22..e38d5073f22 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -2250,7 +2250,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) } /* get a filename for menu */ - BLI_path_split_dir_part(first_ibuf->name, di, sizeof(di)); + BLI_path_split_dir_part(first_ibuf->filepath, di, sizeof(di)); BKE_reportf(op->reports, RPT_INFO, "%d image(s) will be saved in %s", tot, di); iter = IMB_moviecacheIter_new(image->cache); @@ -2258,17 +2258,17 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) ibuf = IMB_moviecacheIter_getImBuf(iter); if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) { - char name[FILE_MAX]; - BLI_strncpy(name, ibuf->name, sizeof(name)); + char filepath[FILE_MAX]; + BLI_strncpy(filepath, ibuf->filepath, sizeof(filepath)); - BLI_path_abs(name, BKE_main_blendfile_path(bmain)); + BLI_path_abs(filepath, BKE_main_blendfile_path(bmain)); - if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) { + if (0 == IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat)) { BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno)); break; } - BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->name); + BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->filepath); ibuf->userflags &= ~IB_BITMAPDIRTY; } diff --git a/source/blender/editors/space_image/image_undo.cc b/source/blender/editors/space_image/image_undo.cc index 04af832f6ac..90cb5695602 100644 --- a/source/blender/editors/space_image/image_undo.cc +++ b/source/blender/editors/space_image/image_undo.cc @@ -440,7 +440,7 @@ struct UndoImageBuf { */ struct UndoImageBuf *post; - char ibuf_name[IMB_FILENAME_SIZE]; + char ibuf_filepath[IMB_FILEPATH_SIZE]; UndoImageTile **tiles; @@ -471,7 +471,7 @@ static UndoImageBuf *ubuf_from_image_no_tiles(Image *image, const ImBuf *ibuf) ubuf->tiles = static_cast( MEM_callocN(sizeof(*ubuf->tiles) * ubuf->tiles_len, __func__)); - BLI_strncpy(ubuf->ibuf_name, ibuf->name, sizeof(ubuf->ibuf_name)); + BLI_strncpy(ubuf->ibuf_filepath, ibuf->filepath, sizeof(ubuf->ibuf_filepath)); ubuf->image_state.source = image->source; ubuf->image_state.use_float = ibuf->rect_float != nullptr; @@ -639,10 +639,10 @@ static void uhandle_free_list(ListBase *undo_handles) static UndoImageBuf *uhandle_lookup_ubuf(UndoImageHandle *uh, const Image * /*image*/, - const char *ibuf_name) + const char *ibuf_filepath) { LISTBASE_FOREACH (UndoImageBuf *, ubuf, &uh->buffers) { - if (STREQ(ubuf->ibuf_name, ibuf_name)) { + if (STREQ(ubuf->ibuf_filepath, ibuf_filepath)) { return ubuf; } } @@ -651,7 +651,7 @@ static UndoImageBuf *uhandle_lookup_ubuf(UndoImageHandle *uh, static UndoImageBuf *uhandle_add_ubuf(UndoImageHandle *uh, Image *image, ImBuf *ibuf) { - BLI_assert(uhandle_lookup_ubuf(uh, image, ibuf->name) == nullptr); + BLI_assert(uhandle_lookup_ubuf(uh, image, ibuf->filepath) == nullptr); UndoImageBuf *ubuf = ubuf_from_image_no_tiles(image, ibuf); BLI_addtail(&uh->buffers, ubuf); @@ -662,7 +662,7 @@ static UndoImageBuf *uhandle_add_ubuf(UndoImageHandle *uh, Image *image, ImBuf * static UndoImageBuf *uhandle_ensure_ubuf(UndoImageHandle *uh, Image *image, ImBuf *ibuf) { - UndoImageBuf *ubuf = uhandle_lookup_ubuf(uh, image, ibuf->name); + UndoImageBuf *ubuf = uhandle_lookup_ubuf(uh, image, ibuf->filepath); if (ubuf == nullptr) { ubuf = uhandle_add_ubuf(uh, image, ibuf); } @@ -745,7 +745,7 @@ static UndoImageBuf *ubuf_lookup_from_reference(ImageUndoStep *us_prev, /* Use name lookup because the pointer is cleared for previous steps. */ UndoImageHandle *uh_prev = uhandle_lookup_by_name(&us_prev->handles, image, tile_number); if (uh_prev != nullptr) { - UndoImageBuf *ubuf_reference = uhandle_lookup_ubuf(uh_prev, image, ubuf->ibuf_name); + UndoImageBuf *ubuf_reference = uhandle_lookup_ubuf(uh_prev, image, ubuf->ibuf_filepath); if (ubuf_reference) { ubuf_reference = ubuf_reference->post; if ((ubuf_reference->image_dims[0] == ubuf->image_dims[0]) && diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp index 00a7644bbde..829de562333 100644 --- a/source/blender/freestyle/intern/stroke/Canvas.cpp +++ b/source/blender/freestyle/intern/stroke/Canvas.cpp @@ -422,11 +422,11 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, uint iNbLevels } } // soc qtmp.save(base + QString::number(i) + ".bmp", "BMP"); - stringstream filename; - filename << base; - filename << i << ".bmp"; + stringstream filepath; + filepath << base; + filepath << i << ".bmp"; qtmp->ftype = IMB_FTYPE_BMP; - IMB_saveiff(qtmp, const_cast(filename.str().c_str()), 0); + IMB_saveiff(qtmp, const_cast(filepath.str().c_str()), 0); } #if 0 diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp index e0ad5de1bf5..8e88b6c41f6 100644 --- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp +++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp @@ -237,7 +237,7 @@ void SteerableViewMap::saveSteerableViewMap() const // soc QString base("SteerableViewMap"); string base("SteerableViewMap"); - stringstream filename; + stringstream filepath; for (int j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) { // soc float coeff = 1.0f; // 1 / 255.0f; // 100 * 255; // * pow(2, j); @@ -261,10 +261,10 @@ void SteerableViewMap::saveSteerableViewMap() const } // soc qtmp.save(base+QString::number(i)+"-"+QString::number(j)+".png", "PNG"); - filename << base; - filename << i << "-" << j << ".png"; + filepath << base; + filepath << i << "-" << j << ".png"; ibuf->ftype = IMB_FTYPE_PNG; - IMB_saveiff(ibuf, const_cast(filename.str().c_str()), 0); + IMB_saveiff(ibuf, const_cast(filepath.str().c_str()), 0); } #if 0 QString base("SteerableViewMap"); diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 43007c315cb..256bd93669d 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -335,7 +335,7 @@ typedef enum eIMBInterpolationFilterMode { * Defaults to BL_proxy within the directory of the animation. */ void IMB_anim_set_index_dir(struct anim *anim, const char *dir); -void IMB_anim_get_fname(struct anim *anim, char *file, int size); +void IMB_anim_get_filename(struct anim *anim, char *filename, int filename_maxncpy); int IMB_anim_index_get_frame_index(struct anim *anim, IMB_Timecode_Type tc, int position); @@ -386,7 +386,7 @@ bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bo /** * \attention Defined in anim_movie.c */ -struct anim *IMB_open_anim(const char *name, +struct anim *IMB_open_anim(const char *filepath, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE]); @@ -791,8 +791,11 @@ void buf_rectfill_area(unsigned char *rect, /** * Exported for image tools in blender, to quickly allocate 32 bits rect. */ -void *imb_alloc_pixels( - unsigned int x, unsigned int y, unsigned int channels, size_t typesize, const char *name); +void *imb_alloc_pixels(unsigned int x, + unsigned int y, + unsigned int channels, + size_t typesize, + const char *alloc_name); bool imb_addrectImBuf(struct ImBuf *ibuf); /** diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 874e038230d..f18116a3301 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -26,7 +26,7 @@ extern "C" { */ #define IMB_MIPMAP_LEVELS 20 -#define IMB_FILENAME_SIZE 1024 +#define IMB_FILEPATH_SIZE 1024 typedef struct DDSData { /** DDS fourcc info */ @@ -221,8 +221,8 @@ typedef struct ImBuf { enum eImbFileType ftype; /** file format specific flags */ ImbFormatOptions foptions; - /** filename associated with this image */ - char name[IMB_FILENAME_SIZE]; + /** The absolute file path associated with this image. */ + char filepath[IMB_FILEPATH_SIZE]; /* memory cache limiter */ /** reference counter for multiple users */ diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 01ff25ffb4a..904f54f6d9e 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -81,9 +81,9 @@ struct anim { int x, y; /* for number */ - char name[1024]; + char filepath[1024]; /* for sequence */ - char first[1024]; + char filepath_first[1024]; /* movie */ void *movie; diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index 76106fce53a..f60201af0b3 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -41,7 +41,7 @@ typedef struct anim_index_entry { } anim_index_entry; struct anim_index { - char name[1024]; + char filepath[1024]; int num_entries; struct anim_index_entry *entries; @@ -51,8 +51,8 @@ struct anim_index_builder; typedef struct anim_index_builder { FILE *fp; - char name[FILE_MAX]; - char temp_name[FILE_MAX]; + char filepath[FILE_MAX]; + char filepath_temp[FILE_MAX]; void *private_data; @@ -63,7 +63,7 @@ typedef struct anim_index_builder { struct anim_index_entry *entry); } anim_index_builder; -anim_index_builder *IMB_index_builder_create(const char *name); +anim_index_builder *IMB_index_builder_create(const char *filepath); void IMB_index_builder_add_entry(anim_index_builder *fp, int frameno, uint64_t seek_pos, diff --git a/source/blender/imbuf/intern/allocimbuf.cc b/source/blender/imbuf/intern/allocimbuf.cc index 30fbeb14224..af7acbb0873 100644 --- a/source/blender/imbuf/intern/allocimbuf.cc +++ b/source/blender/imbuf/intern/allocimbuf.cc @@ -330,7 +330,7 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf) return true; } -void *imb_alloc_pixels(uint x, uint y, uint channels, size_t typesize, const char *name) +void *imb_alloc_pixels(uint x, uint y, uint channels, size_t typesize, const char *alloc_name) { /* Protect against buffer overflow vulnerabilities from files specifying * a width and height that overflow and alloc too little memory. */ @@ -339,7 +339,7 @@ void *imb_alloc_pixels(uint x, uint y, uint channels, size_t typesize, const cha } size_t size = size_t(x) * size_t(y) * size_t(channels) * typesize; - return MEM_callocN(size, name); + return MEM_callocN(size, alloc_name); } bool imb_addrectfloatImBuf(ImBuf *ibuf, const uint channels) diff --git a/source/blender/imbuf/intern/anim_movie.cc b/source/blender/imbuf/intern/anim_movie.cc index 2fdece879ea..0fc3426c8c2 100644 --- a/source/blender/imbuf/intern/anim_movie.cc +++ b/source/blender/imbuf/intern/anim_movie.cc @@ -272,14 +272,14 @@ struct IDProperty *IMB_anim_load_metadata(struct anim *anim) return anim->metadata; } -struct anim *IMB_open_anim(const char *name, +struct anim *IMB_open_anim(const char *filepath, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE]) { struct anim *anim; - BLI_assert(!BLI_path_is_rel(name)); + BLI_assert(!BLI_path_is_rel(filepath)); anim = (struct anim *)MEM_callocN(sizeof(struct anim), "anim struct"); if (anim != nullptr) { @@ -292,7 +292,7 @@ struct anim *IMB_open_anim(const char *name, anim->colorspace, sizeof(anim->colorspace), COLOR_ROLE_DEFAULT_BYTE); } - BLI_strncpy(anim->name, name, sizeof(anim->name)); + BLI_strncpy(anim->filepath, filepath, sizeof(anim->filepath)); anim->ib_flags = ib_flags; anim->streamindex = streamindex; } @@ -343,16 +343,16 @@ static int startavi(struct anim *anim) anim->avi = MEM_cnew("animavi"); if (anim->avi == nullptr) { - printf("Can't open avi: %s\n", anim->name); + printf("Can't open avi: %s\n", anim->filepath); return -1; } - avierror = AVI_open_movie(anim->name, anim->avi); + avierror = AVI_open_movie(anim->filepath, anim->avi); # if defined(_WIN32) if (avierror == AVI_ERROR_COMPRESSION) { AVIFileInit(); - hr = AVIFileOpen(&anim->pfile, anim->name, OF_READ, 0L); + hr = AVIFileOpen(&anim->pfile, anim->filepath, OF_READ, 0L); if (hr == 0) { anim->pfileopen = 1; for (i = 0; i < MAXNUMSTREAMS; i++) { @@ -412,7 +412,7 @@ static int startavi(struct anim *anim) if (avierror != AVI_ERROR_NONE) { AVI_print_error(avierror); - printf("Error loading avi: %s\n", anim->name); + printf("Error loading avi: %s\n", anim->filepath); free_anim_avi(anim); return -1; } @@ -476,7 +476,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position) anim->avi, AVI_FORMAT_RGB32, position, AVI_get_stream(anim->avi, AVIST_VIDEO, 0))); if (tmp == nullptr) { - printf("Error reading frame from AVI: '%s'\n", anim->name); + printf("Error reading frame from AVI: '%s'\n", anim->filepath); IMB_freeImBuf(ibuf); return nullptr; } @@ -520,7 +520,7 @@ static int startffmpeg(struct anim *anim) streamcount = anim->streamindex; - if (avformat_open_input(&pFormatCtx, anim->name, nullptr, nullptr) != 0) { + if (avformat_open_input(&pFormatCtx, anim->filepath, nullptr, nullptr) != 0) { return -1; } @@ -529,7 +529,7 @@ static int startffmpeg(struct anim *anim) return -1; } - av_dump_format(pFormatCtx, 0, anim->name, 0); + av_dump_format(pFormatCtx, 0, anim->filepath, 0); /* Find the video stream */ video_stream_index = -1; @@ -1532,13 +1532,13 @@ static bool anim_getnew(struct anim *anim) free_anim_ffmpeg(anim); #endif - anim->curtype = imb_get_anim_type(anim->name); + anim->curtype = imb_get_anim_type(anim->filepath); switch (anim->curtype) { case ANIM_SEQUENCE: { - ImBuf *ibuf = IMB_loadiffname(anim->name, anim->ib_flags, anim->colorspace); + ImBuf *ibuf = IMB_loadiffname(anim->filepath, anim->ib_flags, anim->colorspace); if (ibuf) { - BLI_strncpy(anim->first, anim->name, sizeof(anim->first)); + BLI_strncpy(anim->filepath_first, anim->filepath, sizeof(anim->filepath_first)); anim->duration_in_frames = 1; IMB_freeImBuf(ibuf); } @@ -1627,10 +1627,10 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, switch (anim->curtype) { case ANIM_SEQUENCE: - pic = an_stringdec(anim->first, head, tail, &digits); + pic = an_stringdec(anim->filepath_first, head, tail, &digits); pic += position; - an_stringenc(anim->name, sizeof(anim->name), head, tail, digits, pic); - ibuf = IMB_loadiffname(anim->name, IB_rect, anim->colorspace); + an_stringenc(anim->filepath, sizeof(anim->filepath), head, tail, digits, pic); + ibuf = IMB_loadiffname(anim->filepath, IB_rect, anim->colorspace); if (ibuf) { anim->cur_position = position; } @@ -1665,7 +1665,8 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, if (filter_y) { IMB_filtery(ibuf); } - BLI_snprintf(ibuf->name, sizeof(ibuf->name), "%s.%04d", anim->name, anim->cur_position + 1); + BLI_snprintf( + ibuf->filepath, sizeof(ibuf->filepath), "%s.%04d", anim->filepath, anim->cur_position + 1); } return ibuf; } diff --git a/source/blender/imbuf/intern/indexer.cc b/source/blender/imbuf/intern/indexer.cc index 248c82a450a..345e909a491 100644 --- a/source/blender/imbuf/intern/indexer.cc +++ b/source/blender/imbuf/intern/indexer.cc @@ -63,27 +63,27 @@ static IMB_Timecode_Type tc_types[] = { * - time code index functions * ---------------------------------------------------------------------- */ -anim_index_builder *IMB_index_builder_create(const char *name) +anim_index_builder *IMB_index_builder_create(const char *filepath) { anim_index_builder *rv = MEM_cnew("index builder"); - fprintf(stderr, "Starting work on index: %s\n", name); + fprintf(stderr, "Starting work on index: %s\n", filepath); - BLI_strncpy(rv->name, name, sizeof(rv->name)); + BLI_strncpy(rv->filepath, filepath, sizeof(rv->filepath)); - BLI_strncpy(rv->temp_name, name, sizeof(rv->temp_name)); - BLI_string_join(rv->temp_name, sizeof(rv->temp_name), name, temp_ext); + BLI_strncpy(rv->filepath_temp, filepath, sizeof(rv->filepath_temp)); + BLI_string_join(rv->filepath_temp, sizeof(rv->filepath_temp), filepath, temp_ext); - BLI_file_ensure_parent_dir_exists(rv->temp_name); + BLI_file_ensure_parent_dir_exists(rv->filepath_temp); - rv->fp = BLI_fopen(rv->temp_name, "wb"); + rv->fp = BLI_fopen(rv->filepath_temp, "wb"); if (!rv->fp) { fprintf(stderr, "Couldn't open index target: %s! " "Index build broken!\n", - rv->temp_name); + rv->filepath_temp); MEM_freeN(rv); return nullptr; } @@ -144,21 +144,21 @@ void IMB_index_builder_finish(anim_index_builder *fp, int rollback) fclose(fp->fp); if (rollback) { - unlink(fp->temp_name); + unlink(fp->filepath_temp); } else { - unlink(fp->name); - BLI_rename(fp->temp_name, fp->name); + unlink(fp->filepath); + BLI_rename(fp->filepath_temp, fp->filepath); } MEM_freeN(fp); } -struct anim_index *IMB_indexer_open(const char *name) +struct anim_index *IMB_indexer_open(const char *filepath) { char header[13]; struct anim_index *idx; - FILE *fp = BLI_fopen(name, "rb"); + FILE *fp = BLI_fopen(filepath, "rb"); int i; if (!fp) { @@ -166,7 +166,7 @@ struct anim_index *IMB_indexer_open(const char *name) } if (fread(header, 12, 1, fp) != 1) { - fprintf(stderr, "Couldn't read indexer file: %s\n", name); + fprintf(stderr, "Couldn't read indexer file: %s\n", filepath); fclose(fp); return nullptr; } @@ -174,20 +174,20 @@ struct anim_index *IMB_indexer_open(const char *name) header[12] = 0; if (memcmp(header, binary_header_str, 8) != 0) { - fprintf(stderr, "Error reading %s: Binary file type string mismatch\n", name); + fprintf(stderr, "Error reading %s: Binary file type string mismatch\n", filepath); fclose(fp); return nullptr; } if (atoi(header + 9) != INDEX_FILE_VERSION) { - fprintf(stderr, "Error reading %s: File version mismatch\n", name); + fprintf(stderr, "Error reading %s: File version mismatch\n", filepath); fclose(fp); return nullptr; } idx = MEM_cnew("anim_index"); - BLI_strncpy(idx->name, name, sizeof(idx->name)); + BLI_strncpy(idx->filepath, filepath, sizeof(idx->filepath)); fseek(fp, 0, SEEK_END); @@ -213,7 +213,7 @@ struct anim_index *IMB_indexer_open(const char *name) } if (UNLIKELY(items_read != idx->num_entries * 5)) { - fprintf(stderr, "Error: Element data size mismatch in: %s\n", name); + fprintf(stderr, "Error: Element data size mismatch in: %s\n", filepath); MEM_freeN(idx->entries); MEM_freeN(idx); fclose(fp); @@ -383,7 +383,7 @@ static void get_index_dir(struct anim *anim, char *index_dir, size_t index_dir_l if (!anim->index_dir[0]) { char filename[FILE_MAXFILE]; char dirname[FILE_MAXDIR]; - BLI_path_split_dir_file(anim->name, dirname, sizeof(dirname), filename, sizeof(filename)); + BLI_path_split_dir_file(anim->filepath, dirname, sizeof(dirname), filename, sizeof(filename)); BLI_path_join(index_dir, index_dir_len, dirname, "BL_proxy", filename); } else { @@ -391,9 +391,9 @@ static void get_index_dir(struct anim *anim, char *index_dir, size_t index_dir_l } } -void IMB_anim_get_fname(struct anim *anim, char *file, int size) +void IMB_anim_get_filename(struct anim *anim, char *filename, int filename_maxncpy) { - BLI_path_split_file_part(anim->name, file, size); + BLI_path_split_file_part(anim->filepath, filename, filename_maxncpy); } static bool get_proxy_filepath(struct anim *anim, @@ -421,7 +421,7 @@ static bool get_proxy_filepath(struct anim *anim, get_index_dir(anim, index_dir, sizeof(index_dir)); - if (BLI_path_ncmp(anim->name, index_dir, FILE_MAXDIR) == 0) { + if (BLI_path_ncmp(anim->filepath, index_dir, FILE_MAXDIR) == 0) { return false; } @@ -846,7 +846,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, memset(context->proxy_ctx, 0, sizeof(context->proxy_ctx)); memset(context->indexer, 0, sizeof(context->indexer)); - if (avformat_open_input(&context->iFormatCtx, anim->name, nullptr, nullptr) != 0) { + if (avformat_open_input(&context->iFormatCtx, anim->filepath, nullptr, nullptr) != 0) { MEM_freeN(context); return nullptr; } diff --git a/source/blender/imbuf/intern/readimage.cc b/source/blender/imbuf/intern/readimage.cc index cf9fd0b3221..1e8bae62ac7 100644 --- a/source/blender/imbuf/intern/readimage.cc +++ b/source/blender/imbuf/intern/readimage.cc @@ -160,7 +160,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S ibuf = IMB_loadifffile(file, flags, colorspace, filepath); if (ibuf) { - BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); } close(file); @@ -239,7 +239,7 @@ ImBuf *IMB_testiffname(const char *filepath, int flags) ibuf = IMB_loadifffile(file, flags | IB_test | IB_multilayer, colorspace, filepath); if (ibuf) { - BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); } close(file); diff --git a/source/blender/io/avi/AVI_avi.h b/source/blender/io/avi/AVI_avi.h index 2dc6554eac0..7315977548e 100644 --- a/source/blender/io/avi/AVI_avi.h +++ b/source/blender/io/avi/AVI_avi.h @@ -221,12 +221,12 @@ typedef enum { /** * Test whether this is an avi-format. */ -bool AVI_is_avi(const char *name); +bool AVI_is_avi(const char *filepath); /** * Open a compressed file, decompress it into memory. */ -AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...); +AviError AVI_open_compress(char *filepath, AviMovie *movie, int streams, ...); /** * Finalize a compressed output stream. @@ -263,7 +263,7 @@ int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num); /** * Open a movie stream from file. */ -AviError AVI_open_movie(const char *name, AviMovie *movie); +AviError AVI_open_movie(const char *filepath, AviMovie *movie); /** * Read a frame from a movie stream. diff --git a/source/blender/io/avi/intern/avi.c b/source/blender/io/avi/intern/avi.c index 4c3daf02046..b33612faa81 100644 --- a/source/blender/io/avi/intern/avi.c +++ b/source/blender/io/avi/intern/avi.c @@ -184,7 +184,7 @@ AviError AVI_print_error(AviError in_error) return in_error; } -bool AVI_is_avi(const char *name) +bool AVI_is_avi(const char *filepath) { int temp, fcca, j; AviMovie movie = {NULL}; @@ -195,7 +195,7 @@ bool AVI_is_avi(const char *name) DEBUG_PRINT("opening movie\n"); movie.type = AVI_MOVIE_READ; - movie.fp = BLI_fopen(name, "rb"); + movie.fp = BLI_fopen(filepath, "rb"); movie.offset_table = NULL; if (movie.fp == NULL) { @@ -379,7 +379,7 @@ bool AVI_is_avi(const char *name) return (movie_tracks != 0); } -AviError AVI_open_movie(const char *name, AviMovie *movie) +AviError AVI_open_movie(const char *filepath, AviMovie *movie) { int temp, fcca, size, j; @@ -388,7 +388,7 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) memset(movie, 0, sizeof(AviMovie)); movie->type = AVI_MOVIE_READ; - movie->fp = BLI_fopen(name, "rb"); + movie->fp = BLI_fopen(filepath, "rb"); movie->offset_table = NULL; if (movie->fp == NULL) { @@ -700,7 +700,7 @@ AviError AVI_close(AviMovie *movie) return AVI_ERROR_NONE; } -AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) +AviError AVI_open_compress(char *filepath, AviMovie *movie, int streams, ...) { va_list ap; AviList list; @@ -711,7 +711,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) int64_t junk_pos; movie->type = AVI_MOVIE_WRITE; - movie->fp = BLI_fopen(name, "wb"); + movie->fp = BLI_fopen(filepath, "wb"); movie->index_entries = 0; diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index e4105831cfb..3f460e3ecca 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -98,7 +98,7 @@ static void rna_Scene_uvedit_aspect(Scene *UNUSED(scene), Object *ob, float aspe } static void rna_SceneRender_get_frame_path( - RenderData *rd, Main *bmain, int frame, bool preview, const char *view, char *name) + RenderData *rd, Main *bmain, int frame, bool preview, const char *view, char *filepath) { const char *suffix = BKE_scene_multiview_view_suffix_get(rd, view); @@ -108,10 +108,10 @@ static void rna_SceneRender_get_frame_path( } if (BKE_imtype_is_movie(rd->im_format.imtype)) { - BKE_movie_filepath_get(name, rd, preview != 0, suffix); + BKE_movie_filepath_get(filepath, rd, preview != 0, suffix); } else { - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, rd->pic, BKE_main_blendfile_path(bmain), (frame == INT_MIN) ? rd->cfra : frame, diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 7f8af23e745..40fb9b138f5 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -963,15 +963,15 @@ static void rna_StudioLights_remove(UserDef *UNUSED(userdef), StudioLight *studi BKE_studiolight_remove(studio_light); } -static StudioLight *rna_StudioLights_load(UserDef *UNUSED(userdef), const char *path, int type) +static StudioLight *rna_StudioLights_load(UserDef *UNUSED(userdef), const char *filepath, int type) { - return BKE_studiolight_load(path, type); + return BKE_studiolight_load(filepath, type); } /* TODO: Make it accept arguments. */ -static StudioLight *rna_StudioLights_new(UserDef *userdef, const char *name) +static StudioLight *rna_StudioLights_new(UserDef *userdef, const char *filepath) { - return BKE_studiolight_create(name, userdef->light_param, userdef->light_ambient); + return BKE_studiolight_create(filepath, userdef->light_param, userdef->light_ambient); } /* StudioLight.name */ @@ -991,13 +991,13 @@ static int rna_UserDef_studiolight_name_length(PointerRNA *ptr) static void rna_UserDef_studiolight_path_get(PointerRNA *ptr, char *value) { StudioLight *sl = (StudioLight *)ptr->data; - BLI_strncpy(value, sl->path, FILE_MAX); + BLI_strncpy(value, sl->filepath, FILE_MAX); } static int rna_UserDef_studiolight_path_length(PointerRNA *ptr) { StudioLight *sl = (StudioLight *)ptr->data; - return strlen(sl->path); + return strlen(sl->filepath); } /* StudioLight.path_irr_cache */ diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c index 0f7de169352..d0deae67415 100644 --- a/source/blender/python/generic/imbuf_py_api.c +++ b/source/blender/python/generic/imbuf_py_api.c @@ -264,7 +264,7 @@ static PyObject *py_imbuf_filepath_get(Py_ImBuf *self, void *UNUSED(closure)) { PY_IMBUF_CHECK_OBJ(self); ImBuf *ibuf = self->ibuf; - return PyC_UnicodeFromBytes(ibuf->name); + return PyC_UnicodeFromBytes(ibuf->filepath); } static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure)) @@ -277,14 +277,14 @@ static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(c } ImBuf *ibuf = self->ibuf; - const Py_ssize_t value_str_len_max = sizeof(ibuf->name); + const Py_ssize_t value_str_len_max = sizeof(ibuf->filepath); Py_ssize_t value_str_len; const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len); if (value_str_len >= value_str_len_max) { PyErr_Format(PyExc_TypeError, "filepath length over %zd", value_str_len_max - 1); return -1; } - memcpy(ibuf->name, value_str, value_str_len + 1); + memcpy(ibuf->filepath, value_str, value_str_len + 1); return 0; } @@ -337,8 +337,11 @@ static PyObject *py_imbuf_repr(Py_ImBuf *self) { const ImBuf *ibuf = self->ibuf; if (ibuf != NULL) { - return PyUnicode_FromFormat( - "", ibuf, ibuf->name, ibuf->x, ibuf->y); + return PyUnicode_FromFormat("", + ibuf, + ibuf->filepath, + ibuf->x, + ibuf->y); } return PyUnicode_FromString(""); @@ -493,7 +496,7 @@ static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject * return NULL; } - BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); return Py_ImBuf_CreatePyObject(ibuf); } @@ -527,7 +530,7 @@ static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject } if (filepath == NULL) { - filepath = py_imb->ibuf->name; + filepath = py_imb->ibuf->filepath; } const bool ok = IMB_saveiff(py_imb->ibuf, filepath, IB_rect); diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index 7f4fcc05a05..2a8a06b59d3 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -160,7 +160,7 @@ static bool do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const int totvideos, - const char *name_override); + const char *filepath_override); /* default callbacks, set in each new render */ static void result_nothing(void * /*arg*/, RenderResult * /*rr*/) {} @@ -1779,8 +1779,8 @@ void RE_RenderFrame(Render *re, printf("Error: can't write single images with a movie format!\n"); } else { - char name[FILE_MAX]; - BKE_image_path_from_imformat(name, + char filepath_override[FILE_MAX]; + BKE_image_path_from_imformat(filepath_override, rd.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, @@ -1790,7 +1790,7 @@ void RE_RenderFrame(Render *re, nullptr); /* reports only used for Movie */ - do_write_image_or_movie(re, bmain, scene, nullptr, 0, name); + do_write_image_or_movie(re, bmain, scene, nullptr, 0, filepath_override); } } @@ -1977,9 +1977,9 @@ static bool do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const int totvideos, - const char *name_override) + const char *filepath_override) { - char name[FILE_MAX]; + char filepath[FILE_MAX]; RenderResult rres; double render_time; bool ok = true; @@ -1998,11 +1998,11 @@ static bool do_write_image_or_movie(Render *re, re->reports, &rres, scene, &re->r, mh, re->movie_ctx_arr, totvideos, false); } else { - if (name_override) { - BLI_strncpy(name, name_override, sizeof(name)); + if (filepath_override) { + BLI_strncpy(filepath, filepath_override, sizeof(filepath)); } else { - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, scene->r.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, @@ -2013,7 +2013,7 @@ static bool do_write_image_or_movie(Render *re, } /* write images as individual images or stereo */ - ok = BKE_image_render_write(re->reports, &rres, scene, true, name); + ok = BKE_image_render_write(re->reports, &rres, scene, true, filepath); } RE_ReleaseResultImageViews(re, &rres); @@ -2022,8 +2022,8 @@ static bool do_write_image_or_movie(Render *re, render_time = re->i.lastframetime; re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime; - BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime); - printf(" Time: %s", name); + BLI_timecode_string_from_time_simple(filepath, sizeof(filepath), re->i.lastframetime); + printf(" Time: %s", filepath); /* Flush stdout to be sure python callbacks are printing stuff after blender. */ fflush(stdout); @@ -2033,8 +2033,9 @@ static bool do_write_image_or_movie(Render *re, render_callback_exec_null(re, G_MAIN, BKE_CB_EVT_RENDER_STATS); if (do_write_file) { - BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime - render_time); - printf(" (Saving: %s)\n", name); + BLI_timecode_string_from_time_simple( + filepath, sizeof(filepath), re->i.lastframetime - render_time); + printf(" (Saving: %s)\n", filepath); } fputc('\n', stdout); @@ -2168,7 +2169,7 @@ void RE_RenderAnim(Render *re, { scene->r.subframe = 0.0f; for (nfra = sfra, scene->r.cfra = sfra; scene->r.cfra <= efra; scene->r.cfra++) { - char name[FILE_MAX]; + char filepath[FILE_MAX]; /* A feedback loop exists here -- render initialization requires updated * render layers settings which could be animated, but scene evaluation for @@ -2204,7 +2205,7 @@ void RE_RenderAnim(Render *re, /* Touch/NoOverwrite options are only valid for image's */ if (is_movie == false && do_write_file) { if (rd.mode & (R_NO_OVERWRITE | R_TOUCH)) { - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, rd.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, @@ -2216,8 +2217,8 @@ void RE_RenderAnim(Render *re, if (rd.mode & R_NO_OVERWRITE) { if (!is_multiview_name) { - if (BLI_exists(name)) { - printf("skipping existing frame \"%s\"\n", name); + if (BLI_exists(filepath)) { + printf("skipping existing frame \"%s\"\n", filepath); totskipped++; continue; } @@ -2231,7 +2232,7 @@ void RE_RenderAnim(Render *re, continue; } - BKE_scene_multiview_filepath_get(srv, name, filepath); + BKE_scene_multiview_filepath_get(srv, filepath, filepath); if (BLI_exists(filepath)) { is_skip = true; @@ -2248,24 +2249,24 @@ void RE_RenderAnim(Render *re, if (rd.mode & R_TOUCH) { if (!is_multiview_name) { - if (!BLI_exists(name)) { - BLI_file_ensure_parent_dir_exists(name); - BLI_file_touch(name); + if (!BLI_exists(filepath)) { + BLI_file_ensure_parent_dir_exists(filepath); + BLI_file_touch(filepath); } } else { - char filepath[FILE_MAX]; + char filepath_view[FILE_MAX]; LISTBASE_FOREACH (SceneRenderView *, srv, &scene->r.views) { if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) { continue; } - BKE_scene_multiview_filepath_get(srv, name, filepath); + BKE_scene_multiview_filepath_get(srv, filepath, filepath_view); - if (!BLI_exists(filepath)) { - BLI_file_ensure_parent_dir_exists(filepath); - BLI_file_touch(filepath); + if (!BLI_exists(filepath_view)) { + BLI_file_ensure_parent_dir_exists(filepath_view); + BLI_file_touch(filepath_view); } } } @@ -2297,24 +2298,24 @@ void RE_RenderAnim(Render *re, if (is_movie == false && do_write_file) { if (rd.mode & R_TOUCH) { if (!is_multiview_name) { - if (BLI_file_size(name) == 0) { - /* BLI_exists(name) is implicit */ - BLI_delete(name, false, false); + if (BLI_file_size(filepath) == 0) { + /* BLI_exists(filepath) is implicit */ + BLI_delete(filepath, false, false); } } else { - char filepath[FILE_MAX]; + char filepath_view[FILE_MAX]; LISTBASE_FOREACH (SceneRenderView *, srv, &scene->r.views) { if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) { continue; } - BKE_scene_multiview_filepath_get(srv, name, filepath); + BKE_scene_multiview_filepath_get(srv, filepath, filepath_view); - if (BLI_file_size(filepath) == 0) { - /* BLI_exists(filepath) is implicit */ - BLI_delete(filepath, false, false); + if (BLI_file_size(filepath_view) == 0) { + /* BLI_exists(filepath_view) is implicit */ + BLI_delete(filepath_view, false, false); } } } diff --git a/source/blender/sequencer/intern/disk_cache.c b/source/blender/sequencer/intern/disk_cache.c index 4f17d3419e6..d20aacf1d46 100644 --- a/source/blender/sequencer/intern/disk_cache.c +++ b/source/blender/sequencer/intern/disk_cache.c @@ -334,11 +334,11 @@ static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache, BLI_path_append(path, path_len, cache_filename); } -static void seq_disk_cache_create_version_file(char *path) +static void seq_disk_cache_create_version_file(char *filepath) { - BLI_file_ensure_parent_dir_exists(path); + BLI_file_ensure_parent_dir_exists(filepath); - FILE *file = BLI_fopen(path, "w"); + FILE *file = BLI_fopen(filepath, "w"); if (file) { fprintf(file, "%d", DCACHE_CURRENT_VERSION); fclose(file); diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c index 1e21d53dad8..de4eb123b01 100644 --- a/source/blender/sequencer/intern/proxy.c +++ b/source/blender/sequencer/intern/proxy.c @@ -96,9 +96,9 @@ double SEQ_rendersize_to_scale_factor(int render_size) return 1.0; } -bool seq_proxy_get_custom_file_fname(Sequence *seq, char *name, const int view_id) +bool seq_proxy_get_custom_file_fname(Sequence *seq, char *filepath, const int view_id) { - char fname[FILE_MAXFILE]; + char filepath_temp[FILE_MAXFILE]; char suffix[24]; StripProxy *proxy = seq->strip->proxy; @@ -106,18 +106,18 @@ bool seq_proxy_get_custom_file_fname(Sequence *seq, char *name, const int view_i return false; } - BLI_path_join(fname, PROXY_MAXFILE, proxy->dir, proxy->file); - BLI_path_abs(fname, BKE_main_blendfile_path_from_global()); + BLI_path_join(filepath_temp, PROXY_MAXFILE, proxy->dir, proxy->file); + BLI_path_abs(filepath_temp, BKE_main_blendfile_path_from_global()); if (view_id > 0) { BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id); /* TODO(sergey): This will actually append suffix after extension * which is weird but how was originally coded in multi-view branch. */ - BLI_snprintf(name, PROXY_MAXFILE, "%s_%s", fname, suffix); + BLI_snprintf(filepath, PROXY_MAXFILE, "%s_%s", filepath_temp, suffix); } else { - BLI_strncpy(name, fname, PROXY_MAXFILE); + BLI_strncpy(filepath, filepath_temp, PROXY_MAXFILE); } return true; @@ -127,7 +127,7 @@ static bool seq_proxy_get_fname(Scene *scene, Sequence *seq, int timeline_frame, eSpaceSeq_Proxy_RenderSize render_size, - char *name, + char *filepath, const int view_id) { char dir[PROXY_MAXFILE]; @@ -148,7 +148,7 @@ static bool seq_proxy_get_fname(Scene *scene, if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE && ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE) { - if (seq_proxy_get_custom_file_fname(seq, name, view_id)) { + if (seq_proxy_get_custom_file_fname(seq, filepath, view_id)) { return true; } } @@ -161,7 +161,7 @@ static bool seq_proxy_get_fname(Scene *scene, else { /* Per project with custom dir. */ BLI_strncpy(dir, ed->proxy_dir, sizeof(dir)); } - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); } else { /* Pre strip with custom dir. */ @@ -176,14 +176,14 @@ static bool seq_proxy_get_fname(Scene *scene, /* Proxy size number to be used in path. */ int proxy_size_number = SEQ_rendersize_to_scale_factor(render_size) * 100; - BLI_snprintf(name, + BLI_snprintf(filepath, PROXY_MAXFILE, "%s/images/%d/%s_proxy%s.jpg", dir, proxy_size_number, SEQ_render_give_stripelem(scene, seq, timeline_frame)->name, suffix); - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); return true; } @@ -199,7 +199,7 @@ bool SEQ_can_use_proxy(const struct SeqRenderData *context, Sequence *seq, int p ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline_frame) { - char name[PROXY_MAXFILE]; + char filepath[PROXY_MAXFILE]; StripProxy *proxy = seq->strip->proxy; const eSpaceSeq_Proxy_RenderSize psize = context->preview_render_size; StripAnim *sanim; @@ -214,11 +214,12 @@ ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline seq->anim_startofs; if (proxy->anim == NULL) { if (seq_proxy_get_fname( - context->scene, seq, timeline_frame, psize, name, context->view_id) == 0) { + context->scene, seq, timeline_frame, psize, filepath, context->view_id) == 0) + { return NULL; } - proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name); + proxy->anim = openanim(filepath, IB_rect, 0, seq->strip->colorspace_settings.name); } if (proxy->anim == NULL) { return NULL; @@ -233,13 +234,14 @@ ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE); } - if (seq_proxy_get_fname(context->scene, seq, timeline_frame, psize, name, context->view_id) == 0) + if (seq_proxy_get_fname( + context->scene, seq, timeline_frame, psize, filepath, context->view_id) == 0) { return NULL; } - if (BLI_exists(name)) { - ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL); + if (BLI_exists(filepath)) { + ImBuf *ibuf = IMB_loadiffname(filepath, IB_rect, NULL); if (ibuf) { seq_imbuf_assign_spaces(context->scene, ibuf); @@ -258,18 +260,19 @@ static void seq_proxy_build_frame(const SeqRenderData *context, int proxy_render_size, const bool overwrite) { - char name[PROXY_MAXFILE]; + char filepath[PROXY_MAXFILE]; int quality; int rectx, recty; ImBuf *ibuf_tmp, *ibuf; Scene *scene = context->scene; - if (!seq_proxy_get_fname(scene, seq, timeline_frame, proxy_render_size, name, context->view_id)) + if (!seq_proxy_get_fname( + scene, seq, timeline_frame, proxy_render_size, filepath, context->view_id)) { return; } - if (!overwrite && BLI_exists(name)) { + if (!overwrite && BLI_exists(filepath)) { return; } @@ -299,11 +302,11 @@ static void seq_proxy_build_frame(const SeqRenderData *context, ibuf->planes = 24; } - BLI_file_ensure_parent_dir_exists(name); + BLI_file_ensure_parent_dir_exists(filepath); - const bool ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); + const bool ok = IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == false) { - perror(name); + perror(filepath); } IMB_freeImBuf(ibuf); @@ -580,12 +583,12 @@ void SEQ_proxy_set(struct Sequence *seq, bool value) void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir) { - char dir[FILE_MAX]; - char fname[FILE_MAXFILE]; + char dirname[FILE_MAX]; + char filename[FILE_MAXFILE]; - IMB_anim_get_fname(anim, fname, FILE_MAXFILE); - BLI_path_join(dir, sizeof(dir), base_dir, fname); - IMB_anim_set_index_dir(anim, dir); + IMB_anim_get_filename(anim, filename, FILE_MAXFILE); + BLI_path_join(dirname, sizeof(dirname), base_dir, filename); + IMB_anim_set_index_dir(anim, dirname); } void free_proxy_seq(Sequence *seq) diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index 63791a1077b..ad23c9c5d27 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -893,7 +893,7 @@ static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context, */ static ImBuf *seq_render_image_strip_view(const SeqRenderData *context, Sequence *seq, - char *name, + char *filepath, char *prefix, const char *ext, int view_id) @@ -907,13 +907,13 @@ static ImBuf *seq_render_image_strip_view(const SeqRenderData *context, } if (prefix[0] == '\0') { - ibuf = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name); + ibuf = IMB_loadiffname(filepath, flag, seq->strip->colorspace_settings.name); } else { - char str[FILE_MAX]; - BKE_scene_multiview_view_prefix_get(context->scene, name, prefix, &ext); - seq_multiview_name(context->scene, view_id, prefix, ext, str, FILE_MAX); - ibuf = IMB_loadiffname(str, flag, seq->strip->colorspace_settings.name); + char filepath_view[FILE_MAX]; + BKE_scene_multiview_view_prefix_get(context->scene, filepath, prefix, &ext); + seq_multiview_name(context->scene, view_id, prefix, ext, filepath_view, FILE_MAX); + ibuf = IMB_loadiffname(filepath_view, flag, seq->strip->colorspace_settings.name); } if (ibuf == NULL) { @@ -953,7 +953,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, float timeline_frame, bool *r_is_proxy_image) { - char name[FILE_MAX]; + char filepath[FILE_MAX]; const char *ext = NULL; char prefix[FILE_MAX]; ImBuf *ibuf = NULL; @@ -963,8 +963,8 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, return NULL; } - BLI_path_join(name, sizeof(name), seq->strip->dir, s_elem->name); - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_join(filepath, sizeof(filepath), seq->strip->dir, s_elem->name); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); /* Try to get a proxy image. */ ibuf = seq_proxy_fetch(context, seq, timeline_frame); @@ -976,14 +976,15 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, /* Proxy not found, render original. */ const int totfiles = seq_num_files(context->scene, seq->views_format, true); bool is_multiview_render = seq_image_strip_is_multiview_render( - context->scene, seq, totfiles, name, prefix, ext); + context->scene, seq, totfiles, filepath, prefix, ext); if (is_multiview_render) { int totviews = BKE_scene_multiview_num_views_get(&context->scene->r); ImBuf **ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs"); for (int view_id = 0; view_id < totfiles; view_id++) { - ibufs_arr[view_id] = seq_render_image_strip_view(context, seq, name, prefix, ext, view_id); + ibufs_arr[view_id] = seq_render_image_strip_view( + context, seq, filepath, prefix, ext, view_id); } if (ibufs_arr[0] == NULL) { @@ -1017,7 +1018,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, MEM_freeN(ibufs_arr); } else { - ibuf = seq_render_image_strip_view(context, seq, name, prefix, ext, context->view_id); + ibuf = seq_render_image_strip_view(context, seq, filepath, prefix, ext, context->view_id); } if (ibuf == NULL) { @@ -1034,12 +1035,12 @@ static ImBuf *seq_render_movie_strip_custom_file_proxy(const SeqRenderData *cont Sequence *seq, int timeline_frame) { - char name[PROXY_MAXFILE]; + char filepath[PROXY_MAXFILE]; StripProxy *proxy = seq->strip->proxy; if (proxy->anim == NULL) { - if (seq_proxy_get_custom_file_fname(seq, name, context->view_id)) { - proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name); + if (seq_proxy_get_custom_file_fname(seq, filepath, context->view_id)) { + proxy->anim = openanim(filepath, IB_rect, 0, seq->strip->colorspace_settings.name); } if (proxy->anim == NULL) { return NULL; diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index ad2a8590772..a790794b360 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -202,16 +202,16 @@ void SEQ_add_image_load_file(Scene *scene, Sequence *seq, size_t strip_frame, ch void SEQ_add_image_init_alpha_mode(Sequence *seq) { if (seq->strip && seq->strip->stripdata) { - char name[FILE_MAX]; + char filepath[FILE_MAX]; ImBuf *ibuf; - BLI_path_join(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_join(filepath, sizeof(filepath), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); /* Initialize input color space. */ if (seq->type == SEQ_TYPE_IMAGE) { ibuf = IMB_loadiffname( - name, IB_test | IB_alphamode_detect, seq->strip->colorspace_settings.name); + filepath, IB_test | IB_alphamode_detect, seq->strip->colorspace_settings.name); /* Byte images are default to straight alpha, however sequencer * works in premul space, so mark strip to be premultiplied first. diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index 21faa34c41a..10e9ccd4d7f 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -209,7 +209,7 @@ ListBase *SEQ_get_seqbase_from_sequence(Sequence *seq, ListBase **r_channels, in void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) { char dir[FILE_MAX]; - char name[FILE_MAX]; + char filepath[FILE_MAX]; StripProxy *proxy; bool use_proxy; bool is_multiview_loaded = false; @@ -224,8 +224,8 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) /* reset all the previously created anims */ SEQ_relations_sequence_free_anim(seq); - BLI_path_join(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_join(filepath, sizeof(filepath), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); proxy = seq->strip->proxy; @@ -253,7 +253,7 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) const char *ext = NULL; int i; - BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext); + BKE_scene_multiview_view_prefix_get(scene, filepath, prefix, &ext); if (prefix[0] != '\0') { for (i = 0; i < totfiles; i++) { @@ -285,13 +285,13 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) } else { if (openfile) { - sanim->anim = openanim(name, + sanim->anim = openanim(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, seq->strip->colorspace_settings.name); } else { - sanim->anim = openanim_noload(name, + sanim->anim = openanim_noload(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, @@ -317,13 +317,13 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) BLI_addtail(&seq->anims, sanim); if (openfile) { - sanim->anim = openanim(name, + sanim->anim = openanim(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, seq->strip->colorspace_settings.name); } else { - sanim->anim = openanim_noload(name, + sanim->anim = openanim_noload(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, seq->strip->colorspace_settings.name); diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index 5a7e8bc65f3..f8eb81b0b34 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -1470,13 +1470,13 @@ void wm_history_file_read(void) return; } - char name[FILE_MAX]; + char filepath[FILE_MAX]; LinkNode *l; int num; - BLI_path_join(name, sizeof(name), cfgdir, BLENDER_HISTORY_FILE); + BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_HISTORY_FILE); - LinkNode *lines = BLI_file_read_as_lines(name); + LinkNode *lines = BLI_file_read_as_lines(filepath); wm_history_files_free(); @@ -1529,7 +1529,7 @@ static RecentFile *wm_file_history_find(const char *filepath) static void wm_history_file_write(void) { const char *user_config_dir; - char name[FILE_MAX]; + char filepath[FILE_MAX]; FILE *fp; /* will be nullptr in background mode */ @@ -1538,9 +1538,9 @@ static void wm_history_file_write(void) return; } - BLI_path_join(name, sizeof(name), user_config_dir, BLENDER_HISTORY_FILE); + BLI_path_join(filepath, sizeof(filepath), user_config_dir, BLENDER_HISTORY_FILE); - fp = BLI_fopen(name, "w"); + fp = BLI_fopen(filepath, "w"); if (fp) { LISTBASE_FOREACH (RecentFile *, recent, &G.recent_files) { fprintf(fp, "%s\n", recent->filepath); diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 6b539985235..88a4d821c83 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -242,7 +242,8 @@ typedef struct PlayAnimPict { struct PlayAnimPict *next, *prev; uchar *mem; int size; - const char *name; + /** The allocated file-path to the image. */ + const char *filepath; struct ImBuf *ibuf; struct anim *anim; int frame; @@ -352,11 +353,11 @@ static ImBuf *ibuf_from_picture(PlayAnimPict *pic) } else if (pic->mem) { /* use correct colorspace here */ - ibuf = IMB_ibImageFromMemory(pic->mem, pic->size, pic->IB_flags, NULL, pic->name); + ibuf = IMB_ibImageFromMemory(pic->mem, pic->size, pic->IB_flags, NULL, pic->filepath); } else { /* use correct colorspace here */ - ibuf = IMB_loadiffname(pic->name, pic->IB_flags, NULL); + ibuf = IMB_loadiffname(pic->filepath, pic->IB_flags, NULL); } return ibuf; @@ -537,7 +538,7 @@ static void playanim_toscreen( PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep) { if (ibuf == NULL) { - printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->name : ""); + printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->filepath : ""); return; } @@ -579,7 +580,7 @@ static void playanim_toscreen( int sizex, sizey; float fsizex_inv, fsizey_inv; char str[32 + FILE_MAX]; - BLI_snprintf(str, sizeof(str), "%s | %.2f frames/s", picture->name, fstep / swaptime); + BLI_snprintf(str, sizeof(str), "%s | %.2f frames/s", picture->filepath, fstep / swaptime); playanim_window_get_size(&sizex, &sizey); fsizex_inv = 1.0f / sizex; @@ -622,11 +623,11 @@ static void playanim_toscreen( } static void build_pict_list_ex( - PlayState *ps, const char *first, int totframes, int fstep, int fontid) + PlayState *ps, const char *filepath_first, int totframes, int fstep, int fontid) { - if (IMB_isanim(first)) { + if (IMB_isanim(filepath_first)) { /* OCIO_TODO: support different input color space */ - struct anim *anim = IMB_open_anim(first, IB_rect, 0, NULL); + struct anim *anim = IMB_open_anim(filepath_first, IB_rect, 0, NULL); if (anim) { int pic; struct ImBuf *ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); @@ -640,12 +641,12 @@ static void build_pict_list_ex( picture->anim = anim; picture->frame = pic; picture->IB_flags = IB_rect; - picture->name = BLI_sprintfN("%s : %4.d", first, pic + 1); + picture->filepath = BLI_sprintfN("%s : %4.d", filepath_first, pic + 1); BLI_addtail(&picsbase, picture); } } else { - printf("couldn't open anim %s\n", first); + printf("couldn't open anim %s\n", filepath_first); } } else { @@ -666,7 +667,7 @@ static void build_pict_list_ex( } fp_decoded; char filepath[FILE_MAX]; - BLI_strncpy(filepath, first, sizeof(filepath)); + BLI_strncpy(filepath, filepath_first, sizeof(filepath)); fp_framenr = BLI_path_sequence_decode(filepath, fp_decoded.head, sizeof(fp_decoded.head), @@ -739,7 +740,7 @@ static void build_pict_list_ex( } picture->mem = mem; - picture->name = BLI_strdup(filepath); + picture->filepath = BLI_strdup(filepath); picture->frame = count; close(file); BLI_addtail(&picsbase, picture); @@ -797,10 +798,11 @@ static void build_pict_list_ex( } } -static void build_pict_list(PlayState *ps, const char *first, int totframes, int fstep, int fontid) +static void build_pict_list( + PlayState *ps, const char *filepath_first, int totframes, int fstep, int fontid) { ps->loading = true; - build_pict_list_ex(ps, first, totframes, fstep, fontid); + build_pict_list_ex(ps, filepath_first, totframes, fstep, fontid); ps->loading = false; } @@ -1078,7 +1080,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) if (g_WS.qual & WS_QUAL_SHIFT) { if (ps->picture && ps->picture->ibuf) { printf(" Name: %s | Speed: %.2f frames/s\n", - ps->picture->ibuf->name, + ps->picture->ibuf->filepath, ps->fstep / swaptime); } } @@ -1702,11 +1704,11 @@ static char *wm_main_playanim_intern(int argc, const char **argv) #endif /* USE_FRAME_CACHE_LIMIT */ - BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, ps.picture->filepath, sizeof(ibuf->filepath)); /* why only windows? (from 2.4x) - campbell */ #ifdef _WIN32 - GHOST_SetTitle(g_WS.ghost_window, ps.picture->name); + GHOST_SetTitle(g_WS.ghost_window, ps.picture->filepath); #endif while (pupdate_time()) { @@ -1796,7 +1798,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) MEM_freeN(ps.picture->mem); } - MEM_freeN((void *)ps.picture->name); + MEM_freeN((void *)ps.picture->filepath); MEM_freeN(ps.picture); } diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c index c733ee617cb..0912aa12019 100644 --- a/source/creator/creator_signals.c +++ b/source/creator/creator_signals.c @@ -98,20 +98,20 @@ static void sig_handle_crash(int signum) if (wm && wm->undo_stack) { struct MemFile *memfile = BKE_undosys_stack_memfile_get_active(wm->undo_stack); if (memfile) { - char fname[FILE_MAX]; + char filepath[FILE_MAX]; if (!(G_MAIN && G_MAIN->filepath[0])) { - BLI_path_join(fname, sizeof(fname), BKE_tempdir_base(), "crash.blend"); + BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_base(), "crash.blend"); } else { - STRNCPY(fname, G_MAIN->filepath); - BLI_path_extension_replace(fname, sizeof(fname), ".crash.blend"); + STRNCPY(filepath, G_MAIN->filepath); + BLI_path_extension_replace(filepath, sizeof(filepath), ".crash.blend"); } - printf("Writing: %s\n", fname); + printf("Writing: %s\n", filepath); fflush(stdout); - BLO_memfile_write_file(memfile, fname); + BLO_memfile_write_file(memfile, filepath); } } # endif @@ -119,17 +119,18 @@ static void sig_handle_crash(int signum) FILE *fp; char header[512]; - char fname[FILE_MAX]; + char filepath[FILE_MAX]; if (!(G_MAIN && G_MAIN->filepath[0])) { - BLI_path_join(fname, sizeof(fname), BKE_tempdir_base(), "blender.crash.txt"); + BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_base(), "blender.crash.txt"); } else { - BLI_path_join(fname, sizeof(fname), BKE_tempdir_base(), BLI_path_basename(G_MAIN->filepath)); - BLI_path_extension_replace(fname, sizeof(fname), ".crash.txt"); + BLI_path_join( + filepath, sizeof(filepath), BKE_tempdir_base(), BLI_path_basename(G_MAIN->filepath)); + BLI_path_extension_replace(filepath, sizeof(filepath), ".crash.txt"); } - printf("Writing: %s\n", fname); + printf("Writing: %s\n", filepath); fflush(stdout); # ifndef BUILD_DATE @@ -147,11 +148,11 @@ static void sig_handle_crash(int signum) /* open the crash log */ errno = 0; - fp = BLI_fopen(fname, "wb"); + fp = BLI_fopen(filepath, "wb"); if (fp == NULL) { fprintf(stderr, "Unable to save '%s': %s\n", - fname, + filepath, errno ? strerror(errno) : "Unknown error opening file"); } else {