From 716a8241d387180fd8ad69cdec33633bc7a0f963 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Jun 2020 09:54:14 +1000 Subject: Cleanup: rename 'name' to 'filepath' for DNA types Using 'name' for the full path of a file reads badly, especially when id.name is used in related code. --- source/blender/blenkernel/intern/bpath.c | 18 ++++++------- source/blender/blenkernel/intern/font.c | 16 +++++------ source/blender/blenkernel/intern/image.c | 38 +++++++++++++-------------- source/blender/blenkernel/intern/image_save.c | 6 ++--- source/blender/blenkernel/intern/library.c | 6 ++--- source/blender/blenkernel/intern/movieclip.c | 26 +++++++++--------- source/blender/blenkernel/intern/packedFile.c | 26 +++++++++--------- source/blender/blenkernel/intern/scene.c | 3 ++- source/blender/blenkernel/intern/seqeffects.c | 4 +-- source/blender/blenkernel/intern/sequencer.c | 9 ++++--- source/blender/blenkernel/intern/sound.c | 8 +++--- source/blender/blenkernel/intern/text.c | 28 ++++++++++---------- 12 files changed, 96 insertions(+), 92 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index f0e23ddad41..10783c741b6 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -564,8 +564,8 @@ void BKE_bpath_traverse_id( * don't make sense to add directories to until the image has been saved * once to give it a meaningful value. */ if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE, IMA_SRC_TILED) && - ima->name[0]) { - if (rewrite_path_fixed(ima->name, visit_cb, absbase, bpath_user_data)) { + ima->filepath[0]) { + if (rewrite_path_fixed(ima->filepath, visit_cb, absbase, bpath_user_data)) { if (flag & BKE_BPATH_TRAVERSE_RELOAD_EDITED) { if (!BKE_image_has_packedfile(ima) && /* image may have been painted onto (and not saved, T44543) */ @@ -643,7 +643,7 @@ void BKE_bpath_traverse_id( case ID_SO: { bSound *sound = (bSound *)id; if (sound->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) { - rewrite_path_fixed(sound->name, visit_cb, absbase, bpath_user_data); + rewrite_path_fixed(sound->filepath, visit_cb, absbase, bpath_user_data); } break; } @@ -655,15 +655,15 @@ void BKE_bpath_traverse_id( break; } case ID_TXT: - if (((Text *)id)->name) { - rewrite_path_alloc(&((Text *)id)->name, visit_cb, absbase, bpath_user_data); + if (((Text *)id)->filepath) { + rewrite_path_alloc(&((Text *)id)->filepath, visit_cb, absbase, bpath_user_data); } break; case ID_VF: { VFont *vfont = (VFont *)id; if (vfont->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) { if (BKE_vfont_is_builtin(vfont) == false) { - rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data); + rewrite_path_fixed(((VFont *)id)->filepath, visit_cb, absbase, bpath_user_data); } } break; @@ -756,15 +756,15 @@ void BKE_bpath_traverse_id( Library *lib = (Library *)id; /* keep packedfile paths always relative to the blend */ if (lib->packedfile == NULL) { - if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) { - BKE_library_filepath_set(bmain, lib, lib->name); + if (rewrite_path_fixed(lib->filepath, visit_cb, absbase, bpath_user_data)) { + BKE_library_filepath_set(bmain, lib, lib->filepath); } } break; } case ID_MC: { MovieClip *clip = (MovieClip *)id; - rewrite_path_fixed(clip->name, visit_cb, absbase, bpath_user_data); + rewrite_path_fixed(clip->filepath, visit_cb, absbase, bpath_user_data); break; } case ID_CF: { diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 5771eb053f7..dfa5ff6975f 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -78,7 +78,7 @@ static void vfont_init_data(ID *id) if (vfd) { vfont->data = vfd; - BLI_strncpy(vfont->name, FO_BUILTIN_NAME, sizeof(vfont->name)); + BLI_strncpy(vfont->filepath, FO_BUILTIN_NAME, sizeof(vfont->filepath)); } /* Free the packed file */ @@ -177,7 +177,7 @@ static int builtin_font_size = 0; bool BKE_vfont_is_builtin(struct VFont *vfont) { - return STREQ(vfont->name, FO_BUILTIN_NAME); + return STREQ(vfont->filepath, FO_BUILTIN_NAME); } void BKE_vfont_builtin_register(void *mem, int size) @@ -237,20 +237,20 @@ static VFontData *vfont_get_data(VFont *vfont) } } else { - pf = BKE_packedfile_new(NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); + pf = BKE_packedfile_new(NULL, vfont->filepath, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); if (vfont->temp_pf == NULL) { vfont->temp_pf = BKE_packedfile_new( - NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); + NULL, vfont->filepath, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); } } if (!pf) { - CLOG_WARN(&LOG, "Font file doesn't exist: %s", vfont->name); + CLOG_WARN(&LOG, "Font file doesn't exist: %s", vfont->filepath); /* DON'T DO THIS * missing file shouldn't modify path! - campbell */ #if 0 - strcpy(vfont->name, FO_BUILTIN_NAME); + strcpy(vfont->filepath, FO_BUILTIN_NAME); #endif pf = get_builtin_packedfile(); } @@ -301,7 +301,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath) if (vfd->name[0] != '\0') { BLI_strncpy(vfont->id.name + 2, vfd->name, sizeof(vfont->id.name) - 2); } - BLI_strncpy(vfont->name, filepath, sizeof(vfont->name)); + BLI_strncpy(vfont->filepath, filepath, sizeof(vfont->filepath)); /* if autopack is on store the packedfile in de font structure */ if (!is_builtin && (G.fileflags & G_FILE_AUTOPACK)) { @@ -333,7 +333,7 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool * /* first search an identical filepath */ for (vfont = bmain->fonts.first; vfont; vfont = vfont->id.next) { - BLI_strncpy(strtest, vfont->name, sizeof(vfont->name)); + BLI_strncpy(strtest, vfont->filepath, sizeof(vfont->filepath)); BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &vfont->id)); if (BLI_path_cmp(strtest, str) == 0) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index b4a3f249c63..24d175511c7 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -648,7 +648,7 @@ char BKE_image_alpha_mode_from_extension_ex(const char *filepath) void BKE_image_alpha_mode_from_extension(Image *image) { - image->alpha_mode = BKE_image_alpha_mode_from_extension_ex(image->name); + image->alpha_mode = BKE_image_alpha_mode_from_extension_ex(image->filepath); } Image *BKE_image_load(Main *bmain, const char *filepath) @@ -668,7 +668,7 @@ Image *BKE_image_load(Main *bmain, const char *filepath) close(file); ima = image_alloc(bmain, BLI_path_basename(filepath), IMA_SRC_FILE, IMA_TYPE_IMAGE); - STRNCPY(ima->name, filepath); + STRNCPY(ima->filepath, filepath); if (BLI_path_extension_check_array(filepath, imb_ext_movie)) { ima->source = IMA_SRC_MOVIE; @@ -694,7 +694,7 @@ Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exist /* first search an identical filepath */ for (ima = bmain->images.first; ima; ima = ima->id.next) { if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) { - STRNCPY(strtest, ima->name); + STRNCPY(strtest, ima->filepath); BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id)); if (BLI_path_cmp(strtest, str) == 0) { @@ -830,7 +830,7 @@ Image *BKE_image_add_generated(Main *bmain, int view_id; const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; - /* STRNCPY(ima->name, name); */ /* don't do this, this writes in ain invalid filepath! */ + /* STRNCPY(ima->filepath, name); */ /* don't do this, this writes in ain invalid filepath! */ ima->gen_x = width; ima->gen_y = height; ima->gen_type = gen_type; @@ -846,7 +846,7 @@ Image *BKE_image_add_generated(Main *bmain, for (view_id = 0; view_id < 2; view_id++) { ImBuf *ibuf; ibuf = add_ibuf_size( - width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings); + width, height, ima->filepath, depth, floatbuf, gen_type, color, &ima->colorspace_settings); int index = tiled ? 0 : IMA_NO_INDEX; int entry = tiled ? 1001 : 0; image_assign_ibuf(ima, ibuf, stereo3d ? view_id : index, entry); @@ -881,7 +881,7 @@ Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name) ima = image_alloc(bmain, name, IMA_SRC_FILE, IMA_TYPE_IMAGE); if (ima) { - STRNCPY(ima->name, ibuf->name); + STRNCPY(ima->filepath, ibuf->name); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ImageTile *tile = BKE_image_get_tile(ima, 0); tile->ok = IMA_OK_LOADED; @@ -981,9 +981,9 @@ void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath) if (totfiles == 1) { ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image packed file"); BLI_addtail(&ima->packedfiles, imapf); - imapf->packedfile = BKE_packedfile_new(reports, ima->name, basepath); + imapf->packedfile = BKE_packedfile_new(reports, ima->filepath, basepath); if (imapf->packedfile) { - STRNCPY(imapf->filepath, ima->name); + STRNCPY(imapf->filepath, ima->filepath); } else { BLI_freelinkN(&ima->packedfiles, imapf); @@ -1020,7 +1020,7 @@ void BKE_image_packfiles_from_mem(ReportList *reports, ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), __func__); BLI_addtail(&ima->packedfiles, imapf); imapf->packedfile = BKE_packedfile_new_from_memory(data, data_len); - STRNCPY(imapf->filepath, ima->name); + STRNCPY(imapf->filepath, ima->filepath); } } @@ -3385,7 +3385,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) * Here we ensure original image path wouldn't be used when saving * generated image. */ - ima->name[0] = '\0'; + ima->filepath[0] = '\0'; } if (ima->source != IMA_SRC_TILED) { @@ -3643,7 +3643,7 @@ bool BKE_image_fill_tile(struct Image *ima, image_free_tile(ima, tile); ImBuf *tile_ibuf = add_ibuf_size( - width, height, ima->name, planes, is_float, gen_type, color, &ima->colorspace_settings); + width, height, ima->filepath, planes, is_float, gen_type, color, &ima->colorspace_settings); if (tile_ibuf != NULL) { image_assign_ibuf(ima, tile_ibuf, 0, tile->tile_number); @@ -3807,7 +3807,7 @@ bool BKE_image_is_openexr(struct Image *ima) { #ifdef WITH_OPENEXR if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_TILED)) { - return BLI_path_extension_check(ima->name, ".exr"); + return BLI_path_extension_check(ima->filepath, ".exr"); } #else UNUSED_VARS(ima); @@ -4893,7 +4893,7 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock) } ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, - ima->name, + ima->filepath, ima->gen_depth, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, @@ -5300,11 +5300,11 @@ void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath) BLI_strncpy(filepath, iv->filepath, FILE_MAX); } else { - BLI_strncpy(filepath, ima->name, FILE_MAX); + BLI_strncpy(filepath, ima->filepath, FILE_MAX); } } else { - BLI_strncpy(filepath, ima->name, FILE_MAX); + BLI_strncpy(filepath, ima->filepath, FILE_MAX); } if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_TILED)) { @@ -5461,7 +5461,7 @@ float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame, int int BKE_image_sequence_guess_offset(Image *image) { - return BLI_path_sequence_decode(image->name, NULL, NULL, NULL); + return BLI_path_sequence_decode(image->filepath, NULL, NULL, NULL); } bool BKE_image_has_anim(Image *ima) @@ -5478,7 +5478,7 @@ bool BKE_image_has_filepath(Image *ima) { /* This could be improved to detect cases like //../../, currently path * remapping empty file paths empty. */ - return ima->name[0] != '\0'; + return ima->filepath[0] != '\0'; } /* Checks the image buffer changes with time (not keyframed values). */ @@ -5653,14 +5653,14 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; for (i = 0; i < 2; i++) { - image_add_view(ima, names[i], ima->name); + image_add_view(ima, names[i], ima->filepath); } return; } else { /* R_IMF_VIEWS_INDIVIDUAL */ char prefix[FILE_MAX] = {'\0'}; - char *name = ima->name; + char *name = ima->filepath; const char *ext = NULL; BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext); diff --git a/source/blender/blenkernel/intern/image_save.c b/source/blender/blenkernel/intern/image_save.c index c034fe895a6..19eb3380b8e 100644 --- a/source/blender/blenkernel/intern/image_save.c +++ b/source/blender/blenkernel/intern/image_save.c @@ -73,7 +73,7 @@ static void image_save_post(ReportList *reports, if (opts->do_newpath) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); - BLI_strncpy(ima->name, filepath, sizeof(ima->name)); + BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath)); } ibuf->userflags &= ~IB_BITMAPDIRTY; @@ -106,7 +106,7 @@ static void image_save_post(ReportList *reports, /* only image path, never ibuf */ if (opts->relative) { const char *relbase = ID_BLEND_PATH(opts->bmain, &ima->id); - BLI_path_rel(ima->name, relbase); /* only after saving */ + BLI_path_rel(ima->filepath, relbase); /* only after saving */ } ColorManagedColorspaceSettings old_colorspace_settings; @@ -135,7 +135,7 @@ static void imbuf_save_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf) /** * \return success. - * \note ``ima->name`` and ``ibuf->name`` should end up the same. + * \note ``ima->filepath`` and ``ibuf->name`` should end up the same. * \note for multiview the first ``ibuf`` is important to get the settings. */ static bool image_save_single(ReportList *reports, diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index f9432eaab3f..48c98be626d 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -81,8 +81,8 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath) { /* in some cases this is used to update the absolute path from the * relative */ - if (lib->name != filepath) { - BLI_strncpy(lib->name, filepath, sizeof(lib->name)); + if (lib->filepath != filepath) { + BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath)); } BLI_strncpy(lib->filepath_abs, filepath, sizeof(lib->filepath_abs)); @@ -96,7 +96,7 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath) * since making local could cause this to be directly linked - campbell */ /* Never make paths relative to parent lib - reading code (blenloader) always set *all* - * lib->name relative to current main, not to their parent for indirectly linked ones. */ + * `lib->filepath` relative to current main, not to their parent for indirectly linked ones. */ const char *basepath = BKE_main_blendfile_path(bmain); BLI_path_abs(lib->filepath_abs, basepath); } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index fe7c2055aef..f0efc9b8c50 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -220,19 +220,19 @@ static void get_sequence_fname(const MovieClip *clip, const int framenr, char *n char head[FILE_MAX], tail[FILE_MAX]; int offset; - BLI_strncpy(name, clip->name, sizeof(clip->name)); + BLI_strncpy(name, clip->filepath, sizeof(clip->filepath)); BLI_path_sequence_decode(name, head, tail, &numlen); /* Movie-clips always points to first image from sequence, auto-guess offset for now. * Could be something smarter in the future. */ - offset = sequence_guess_offset(clip->name, strlen(head), numlen); + offset = sequence_guess_offset(clip->filepath, strlen(head), numlen); if (numlen) { BLI_path_sequence_encode( name, head, tail, numlen, offset + framenr - clip->start_frame + clip->frame_offset); } else { - BLI_strncpy(name, clip->name, sizeof(clip->name)); + BLI_strncpy(name, clip->filepath, sizeof(clip->filepath)); } BLI_path_abs(name, ID_BLEND_PATH_FROM_GLOBAL(&clip->id)); @@ -246,7 +246,7 @@ static void get_proxy_fname( char dir[FILE_MAX], clipdir[FILE_MAX], clipfile[FILE_MAX]; int proxynr = framenr - clip->start_frame + 1 + clip->frame_offset; - BLI_split_dirfile(clip->name, clipdir, clipfile, FILE_MAX, FILE_MAX); + BLI_split_dirfile(clip->filepath, clipdir, clipfile, FILE_MAX, FILE_MAX); if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) { BLI_strncpy(dir, clip->proxy.dir, sizeof(dir)); @@ -395,7 +395,7 @@ static void movieclip_open_anim_file(MovieClip *clip) char str[FILE_MAX]; if (!clip->anim) { - BLI_strncpy(str, clip->name, FILE_MAX); + BLI_strncpy(str, clip->filepath, FILE_MAX); BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&clip->id)); /* FIXME: make several stream accessible in image editor, too */ @@ -445,7 +445,7 @@ static void movieclip_calc_length(MovieClip *clip) unsigned short numlen; char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX]; - BLI_path_sequence_decode(clip->name, head, tail, &numlen); + BLI_path_sequence_decode(clip->filepath, head, tail, &numlen); if (numlen == 0) { /* there's no number group in file name, assume it's single framed sequence */ @@ -531,10 +531,10 @@ static int user_frame_to_cache_frame(MovieClip *clip, int framenr) unsigned short numlen; char head[FILE_MAX], tail[FILE_MAX]; - BLI_path_sequence_decode(clip->name, head, tail, &numlen); + BLI_path_sequence_decode(clip->filepath, head, tail, &numlen); /* see comment in get_sequence_fname */ - clip->cache->sequence_offset = sequence_guess_offset(clip->name, strlen(head), numlen); + clip->cache->sequence_offset = sequence_guess_offset(clip->filepath, strlen(head), numlen); } index += clip->cache->sequence_offset; @@ -674,7 +674,7 @@ static bool put_imbuf_cache( clip->cache->sequence_offset = -1; if (clip->source == MCLIP_SRC_SEQUENCE) { unsigned short numlen; - BLI_path_sequence_decode(clip->name, NULL, NULL, &numlen); + BLI_path_sequence_decode(clip->filepath, NULL, NULL, &numlen); clip->cache->is_still_sequence = (numlen == 0); } } @@ -758,7 +758,7 @@ static void detect_clip_source(Main *bmain, MovieClip *clip) ImBuf *ibuf; char name[FILE_MAX]; - BLI_strncpy(name, clip->name, sizeof(name)); + BLI_strncpy(name, clip->filepath, sizeof(name)); BLI_path_abs(name, BKE_main_blendfile_path(bmain)); ibuf = IMB_testiffname(name, IB_rect | IB_multilayer); @@ -795,7 +795,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) /* create a short library name */ clip = movieclip_alloc(bmain, BLI_path_basename(name)); - BLI_strncpy(clip->name, name, sizeof(clip->name)); + BLI_strncpy(clip->filepath, name, sizeof(clip->filepath)); detect_clip_source(bmain, clip); @@ -821,7 +821,7 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b /* first search an identical filepath */ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) { - BLI_strncpy(strtest, clip->name, sizeof(clip->name)); + BLI_strncpy(strtest, clip->filepath, sizeof(clip->filepath)); BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &clip->id)); if (BLI_path_cmp(strtest, str) == 0) { @@ -1739,7 +1739,7 @@ void BKE_movieclip_filename_for_frame(MovieClip *clip, MovieClipUser *user, char } } else { - BLI_strncpy(name, clip->name, FILE_MAX); + BLI_strncpy(name, clip->filepath, FILE_MAX); BLI_path_abs(name, ID_BLEND_PATH_FROM_GLOBAL(&clip->id)); } } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 476d1a3a91f..2cd5588ccb8 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -264,14 +264,16 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose) for (vfont = bmain->fonts.first; vfont; vfont = vfont->id.next) { if (vfont->packedfile == NULL && !ID_IS_LINKED(vfont) && BKE_vfont_is_builtin(vfont) == false) { - vfont->packedfile = BKE_packedfile_new(reports, vfont->name, BKE_main_blendfile_path(bmain)); + vfont->packedfile = BKE_packedfile_new( + reports, vfont->filepath, BKE_main_blendfile_path(bmain)); tot++; } } for (sound = bmain->sounds.first; sound; sound = sound->id.next) { if (sound->packedfile == NULL && !ID_IS_LINKED(sound)) { - sound->packedfile = BKE_packedfile_new(reports, sound->name, BKE_main_blendfile_path(bmain)); + sound->packedfile = BKE_packedfile_new( + reports, sound->filepath, BKE_main_blendfile_path(bmain)); tot++; } } @@ -566,14 +568,14 @@ int BKE_packedfile_unpack_vfont(Main *bmain, if (vfont != NULL) { unpack_generate_paths( - vfont->name, (ID *)vfont, absname, localname, sizeof(absname), sizeof(localname)); + vfont->filepath, (ID *)vfont, absname, localname, sizeof(absname), sizeof(localname)); newname = BKE_packedfile_unpack_to_file( reports, BKE_main_blendfile_path(bmain), absname, localname, vfont->packedfile, how); if (newname != NULL) { ret_value = RET_OK; BKE_packedfile_free(vfont->packedfile); vfont->packedfile = NULL; - BLI_strncpy(vfont->name, newname, sizeof(vfont->name)); + BLI_strncpy(vfont->filepath, newname, sizeof(vfont->filepath)); MEM_freeN(newname); } } @@ -592,11 +594,11 @@ int BKE_packedfile_unpack_sound(Main *bmain, if (sound != NULL) { unpack_generate_paths( - sound->name, (ID *)sound, absname, localname, sizeof(absname), sizeof(localname)); + sound->filepath, (ID *)sound, absname, localname, sizeof(absname), sizeof(localname)); newname = BKE_packedfile_unpack_to_file( reports, BKE_main_blendfile_path(bmain), absname, localname, sound->packedfile, how); if (newname != NULL) { - BLI_strncpy(sound->name, newname, sizeof(sound->name)); + BLI_strncpy(sound->filepath, newname, sizeof(sound->filepath)); MEM_freeN(newname); BKE_packedfile_free(sound->packedfile); @@ -644,7 +646,7 @@ int BKE_packedfile_unpack_image(Main *bmain, /* keep the new name in the image for non-pack specific reasons */ if (how != PF_REMOVE) { - BLI_strncpy(ima->name, newname, sizeof(imapf->filepath)); + BLI_strncpy(ima->filepath, newname, sizeof(imapf->filepath)); } MEM_freeN(newname); } @@ -701,7 +703,7 @@ int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports) int ret_value = RET_ERROR; for (lib = bmain->libraries.first; lib; lib = lib->id.next) { - if (lib->packedfile && lib->name[0]) { + if (lib->packedfile && lib->filepath[0]) { newname = BKE_packedfile_unpack_to_file(reports, BKE_main_blendfile_path(bmain), @@ -731,19 +733,19 @@ void BKE_packedfile_pack_all_libraries(Main *bmain, ReportList *reports) /* test for relativenss */ for (lib = bmain->libraries.first; lib; lib = lib->id.next) { - if (!BLI_path_is_rel(lib->name)) { + if (!BLI_path_is_rel(lib->filepath)) { break; } } if (lib) { - BKE_reportf(reports, RPT_ERROR, "Cannot pack absolute file: '%s'", lib->name); + BKE_reportf(reports, RPT_ERROR, "Cannot pack absolute file: '%s'", lib->filepath); return; } for (lib = bmain->libraries.first; lib; lib = lib->id.next) { if (lib->packedfile == NULL) { - lib->packedfile = BKE_packedfile_new(reports, lib->name, BKE_main_blendfile_path(bmain)); + lib->packedfile = BKE_packedfile_new(reports, lib->filepath, BKE_main_blendfile_path(bmain)); } } } @@ -844,7 +846,7 @@ void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, enum ePF } case ID_LI: { Library *li = (Library *)id; - BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name); + BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->filepath); break; } default: diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 0537f1a65ad..b0faa555f29 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -2293,7 +2293,8 @@ static char *scene_undo_depsgraph_gen_key(Scene *scene, ViewLayer *view_layer, c size_t key_full_offset = BLI_strncpy_rlen(key_full, scene->id.name, MAX_ID_NAME); if (scene->id.lib != NULL) { - key_full_offset += BLI_strncpy_rlen(key_full + key_full_offset, scene->id.lib->name, FILE_MAX); + key_full_offset += BLI_strncpy_rlen( + key_full + key_full_offset, scene->id.lib->filepath, FILE_MAX); } key_full_offset += BLI_strncpy_rlen(key_full + key_full_offset, view_layer->name, MAX_NAME); BLI_assert(key_full_offset < MAX_ID_NAME + FILE_MAX + MAX_NAME); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 5527a4aabdd..de233a8d473 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -3821,7 +3821,7 @@ void BKE_sequencer_text_font_load(TextVars *data, const bool do_id_user) } char path[FILE_MAX]; - STRNCPY(path, data->text_font->name); + STRNCPY(path, data->text_font->filepath); BLI_assert(BLI_thread_is_main()); BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&data->text_font->id)); @@ -3895,7 +3895,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context, data->text_blf_id = -1; if (data->text_font) { - data->text_blf_id = BLF_load(data->text_font->name); + data->text_blf_id = BLF_load(data->text_font->filepath); } } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5da6435436d..096f6fa6bc6 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -406,17 +406,18 @@ static void seqclipboard_ptr_restore(Main *bmain, ID **id_pt) /* check for a data with the same filename */ switch (GS(ID_PT->name)) { case ID_SO: { - id_restore = BLI_findstring(lb, ((bSound *)ID_PT)->name, offsetof(bSound, name)); + id_restore = BLI_findstring(lb, ((bSound *)ID_PT)->filepath, offsetof(bSound, filepath)); if (id_restore == NULL) { - id_restore = BKE_sound_new_file(bmain, ((bSound *)ID_PT)->name); + id_restore = BKE_sound_new_file(bmain, ((bSound *)ID_PT)->filepath); (ID_PT)->newid = id_restore; /* reuse next time */ } break; } case ID_MC: { - id_restore = BLI_findstring(lb, ((MovieClip *)ID_PT)->name, offsetof(MovieClip, name)); + id_restore = BLI_findstring( + lb, ((MovieClip *)ID_PT)->filepath, offsetof(MovieClip, filepath)); if (id_restore == NULL) { - id_restore = BKE_movieclip_file_add(bmain, ((MovieClip *)ID_PT)->name); + id_restore = BKE_movieclip_file_add(bmain, ((MovieClip *)ID_PT)->filepath); (ID_PT)->newid = id_restore; /* reuse next time */ } break; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index e8f31594cc0..a293bc55073 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -172,7 +172,7 @@ bSound *BKE_sound_new_file(Main *bmain, const char *filepath) BLI_path_abs(str, path); sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath), 0); - BLI_strncpy(sound->name, filepath, FILE_MAX); + BLI_strncpy(sound->filepath, filepath, FILE_MAX); /* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */ sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock"); @@ -193,7 +193,7 @@ bSound *BKE_sound_new_file_exists_ex(Main *bmain, const char *filepath, bool *r_ /* first search an identical filepath */ for (sound = bmain->sounds.first; sound; sound = sound->id.next) { - BLI_strncpy(strtest, sound->name, sizeof(sound->name)); + BLI_strncpy(strtest, sound->filepath, sizeof(sound->filepath)); BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &sound->id)); if (BLI_path_cmp(strtest, str) == 0) { @@ -452,8 +452,8 @@ static void sound_load_audio(Main *bmain, bSound *sound, bool free_waveform) /* load sound */ PackedFile *pf = sound->packedfile; - /* don't modify soundact->sound->name, only change a copy */ - BLI_strncpy(fullpath, sound->name, sizeof(fullpath)); + /* don't modify soundact->sound->filepath, only change a copy */ + BLI_strncpy(fullpath, sound->filepath, sizeof(fullpath)); BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id)); /* but we need a packed file then */ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index bce2266f3e9..b7a7b09a11d 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -63,14 +63,14 @@ * How Texts should work * -- * A text should relate to a file as follows - - * (Text *)->name should be the place where the + * (Text *)->filepath should be the place where the * file will or has been saved. * * (Text *)->flags has the following bits * TXT_ISDIRTY - should always be set if the file in mem. differs from * the file on disk, or if there is no file on disk. * TXT_ISMEM - should always be set if the Text has not been mapped to - * a file, in which case (Text *)->name may be NULL or garbage. + * a file, in which case (Text *)->filepath may be NULL or garbage. * TXT_ISEXT - should always be set if the Text is not to be written into * the .blend * TXT_ISSCRIPT - should be set if the user has designated the text @@ -110,7 +110,7 @@ static void text_init_data(ID *id) BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(text, id)); - text->name = NULL; + text->filepath = NULL; text->nlines = 1; text->flags = TXT_ISDIRTY | TXT_ISMEM; @@ -157,8 +157,8 @@ static void text_copy_data(Main *UNUSED(bmain), const Text *text_src = (Text *)id_src; /* File name can be NULL. */ - if (text_src->name) { - text_dst->name = BLI_strdup(text_src->name); + if (text_src->filepath) { + text_dst->filepath = BLI_strdup(text_src->filepath); } text_dst->flags |= TXT_ISDIRTY; @@ -190,7 +190,7 @@ static void text_free_data(ID *id) BKE_text_free_lines(text); - MEM_SAFE_FREE(text->name); + MEM_SAFE_FREE(text->filepath); #ifdef WITH_PYTHON BPY_text_free_code(text); #endif @@ -384,11 +384,11 @@ bool BKE_text_reload(Text *text) char filepath_abs[FILE_MAX]; BLI_stat_t st; - if (!text->name) { + if (!text->filepath) { return false; } - BLI_strncpy(filepath_abs, text->name, FILE_MAX); + BLI_strncpy(filepath_abs, text->filepath, FILE_MAX); BLI_path_abs(filepath_abs, ID_BLEND_PATH_FROM_GLOBAL(&text->id)); buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len); @@ -444,8 +444,8 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const } if (is_internal == false) { - ta->name = MEM_mallocN(strlen(file) + 1, "text_name"); - strcpy(ta->name, file); + ta->filepath = MEM_mallocN(strlen(file) + 1, "text_name"); + strcpy(ta->filepath, file); } else { ta->flags |= TXT_ISMEM | TXT_ISDIRTY; @@ -503,11 +503,11 @@ int BKE_text_file_modified_check(Text *text) int result; char file[FILE_MAX]; - if (!text->name) { + if (!text->filepath) { return 0; } - BLI_strncpy(file, text->name, FILE_MAX); + BLI_strncpy(file, text->filepath, FILE_MAX); BLI_path_abs(file, ID_BLEND_PATH_FROM_GLOBAL(&text->id)); if (!BLI_exists(file)) { @@ -537,11 +537,11 @@ void BKE_text_file_modified_ignore(Text *text) int result; char file[FILE_MAX]; - if (!text->name) { + if (!text->filepath) { return; } - BLI_strncpy(file, text->name, FILE_MAX); + BLI_strncpy(file, text->filepath, FILE_MAX); BLI_path_abs(file, ID_BLEND_PATH_FROM_GLOBAL(&text->id)); if (!BLI_exists(file)) { -- cgit v1.2.3