From 084d545202c27fda5117817491c8d5761b4daafc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Jul 2019 23:57:35 +1000 Subject: Cleanup: use BKE_packedfile prefix for function names Avoid ambiguity with terms check & compare. --- source/blender/blenkernel/BKE_packedFile.h | 76 +++++++------ source/blender/blenkernel/intern/font.c | 25 ++--- source/blender/blenkernel/intern/image.c | 17 +-- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/packedFile.c | 117 +++++++++++---------- source/blender/blenkernel/intern/sound.c | 4 +- .../editors/interface/interface_templates.c | 2 +- source/blender/editors/sound/sound_ops.c | 5 +- source/blender/editors/space_image/image_ops.c | 10 +- source/blender/editors/space_info/info_ops.c | 14 +-- source/blender/editors/util/ed_util.c | 4 +- source/blender/makesrna/intern/rna_image_api.c | 4 +- source/blender/makesrna/intern/rna_sound_api.c | 4 +- source/blender/makesrna/intern/rna_vfont_api.c | 4 +- source/blender/windowmanager/intern/wm_files.c | 2 +- 15 files changed, 154 insertions(+), 136 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index ad0f474a730..9eeb2ba076e 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -34,49 +34,63 @@ struct VFont; struct bSound; /* pack */ -struct PackedFile *dupPackedFile(const struct PackedFile *pf_src); -struct PackedFile *newPackedFile(struct ReportList *reports, - const char *filename, - const char *relabase); -struct PackedFile *newPackedFileMemory(void *mem, int memlen); +struct PackedFile *BKE_packedfile_duplicate(const struct PackedFile *pf_src); +struct PackedFile *BKE_packedfile_new(struct ReportList *reports, + const char *filename, + const char *relabase); +struct PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen); -void packAll(struct Main *bmain, struct ReportList *reports, bool verbose); -void packLibraries(struct Main *bmain, struct ReportList *reports); +void BKE_packedfile_pack_all(struct Main *bmain, struct ReportList *reports, bool verbose); +void BKE_packedfile_pack_all_libraries(struct Main *bmain, struct ReportList *reports); /* unpack */ -char *unpackFile(struct ReportList *reports, - const char *ref_file_name, - const char *abs_name, - const char *local_name, - struct PackedFile *pf, - int how); -int unpackVFont(struct Main *bmain, struct ReportList *reports, struct VFont *vfont, int how); -int unpackSound(struct Main *bmain, struct ReportList *reports, struct bSound *sound, int how); -int unpackImage(struct Main *bmain, struct ReportList *reports, struct Image *ima, int how); -void unpackAll(struct Main *bmain, struct ReportList *reports, int how); -int unpackLibraries(struct Main *bmain, struct ReportList *reports); +char *BKE_packedfile_unpack_to_file(struct ReportList *reports, + const char *ref_file_name, + const char *abs_name, + const char *local_name, + struct PackedFile *pf, + int how); +int BKE_packedfile_unpack_vfont(struct Main *bmain, + struct ReportList *reports, + struct VFont *vfont, + int how); +int BKE_packedfile_unpack_sound(struct Main *bmain, + struct ReportList *reports, + struct bSound *sound, + int how); +int BKE_packedfile_unpack_image(struct Main *bmain, + struct ReportList *reports, + struct Image *ima, + int how); +void BKE_packedfile_unpack_all(struct Main *bmain, struct ReportList *reports, int how); +int BKE_packedfile_unpack_all_libraries(struct Main *bmain, struct ReportList *reports); -int writePackedFile(struct ReportList *reports, - const char *ref_file_name, - const char *filename, - struct PackedFile *pf, - const bool guimode); +int BKE_packedfile_write_to_file(struct ReportList *reports, + const char *ref_file_name, + const char *filename, + struct PackedFile *pf, + const bool guimode); /* free */ -void freePackedFile(struct PackedFile *pf); +void BKE_packedfile_free(struct PackedFile *pf); /* info */ -int countPackedFiles(struct Main *bmain); -int checkPackedFile(const char *ref_file_name, const char *filename, struct PackedFile *pf); +int BKE_packedfile_count_all(struct Main *bmain); +int BKE_packedfile_compare_to_file(const char *ref_file_name, + const char *filename, + struct PackedFile *pf); /* read */ -int seekPackedFile(struct PackedFile *pf, int offset, int whence); -void rewindPackedFile(struct PackedFile *pf); -int readPackedFile(struct PackedFile *pf, void *data, int size); +int BKE_packedfile_seek(struct PackedFile *pf, int offset, int whence); +void BKE_packedfile_rewind(struct PackedFile *pf); +int BKE_packedfile_read(struct PackedFile *pf, void *data, int size); /* ID should be not NULL, return 1 if there's a packed file */ -bool BKE_pack_check(struct ID *id); +bool BKE_packedfile_id_check(struct ID *id); /* ID should be not NULL, throws error when ID is Library */ -void BKE_unpack_id(struct Main *bmain, struct ID *id, struct ReportList *reports, int how); +void BKE_packedfile_id_unpack(struct Main *bmain, + struct ID *id, + struct ReportList *reports, + int how); #endif diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 3f8fc697c6c..a0216e9b413 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -86,7 +86,7 @@ void BKE_vfont_free_data(struct VFont *vfont) } if (vfont->temp_pf) { - freePackedFile(vfont->temp_pf); /* NULL when the font file can't be found on disk */ + BKE_packedfile_free(vfont->temp_pf); /* NULL when the font file can't be found on disk */ vfont->temp_pf = NULL; } } @@ -97,7 +97,7 @@ void BKE_vfont_free(struct VFont *vf) BKE_vfont_free_data(vf); if (vf->packedfile) { - freePackedFile(vf->packedfile); + BKE_packedfile_free(vf->packedfile); vf->packedfile = NULL; } } @@ -114,7 +114,7 @@ void BKE_vfont_copy_data(Main *UNUSED(bmain), vfont_dst->temp_pf = NULL; if (vfont_dst->packedfile) { - vfont_dst->packedfile = dupPackedFile(vfont_dst->packedfile); + vfont_dst->packedfile = BKE_packedfile_duplicate(vfont_dst->packedfile); } if (vfont_dst->data) { @@ -148,7 +148,7 @@ static PackedFile *get_builtin_packedfile(void) memcpy(mem, builtin_font_data, builtin_font_size); - return newPackedFileMemory(mem, builtin_font_size); + return BKE_packedfile_new_from_memory(mem, builtin_font_size); } } @@ -183,14 +183,15 @@ static VFontData *vfont_get_data(VFont *vfont) /* We need to copy a tmp font to memory unless it is already there */ if (vfont->temp_pf == NULL) { - vfont->temp_pf = dupPackedFile(pf); + vfont->temp_pf = BKE_packedfile_duplicate(pf); } } else { - pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); + pf = BKE_packedfile_new(NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); if (vfont->temp_pf == NULL) { - vfont->temp_pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); + vfont->temp_pf = BKE_packedfile_new( + NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); } } if (!pf) { @@ -208,7 +209,7 @@ static VFontData *vfont_get_data(VFont *vfont) if (pf) { vfont->data = BLI_vfontdata_from_freetypefont(pf); if (pf != vfont->packedfile) { - freePackedFile(pf); + BKE_packedfile_free(pf); } } @@ -234,7 +235,7 @@ void BKE_vfont_init(VFont *vfont) } /* Free the packed file */ - freePackedFile(pf); + BKE_packedfile_free(pf); } } @@ -253,7 +254,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath) } else { BLI_split_file_part(filepath, filename, sizeof(filename)); - pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain)); + pf = BKE_packedfile_new(NULL, filepath, BKE_main_blendfile_path(bmain)); is_builtin = false; } @@ -279,13 +280,13 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath) /* Do not add FO_BUILTIN_NAME to temporary listbase */ if (!STREQ(filename, FO_BUILTIN_NAME)) { - vfont->temp_pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain)); + vfont->temp_pf = BKE_packedfile_new(NULL, filepath, BKE_main_blendfile_path(bmain)); } } /* Free the packed file */ if (!vfont || vfont->packedfile != pf) { - freePackedFile(pf); + BKE_packedfile_free(pf); } } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 72bad56990f..f03ca46b34e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -198,7 +198,7 @@ static void image_free_packedfiles(Image *ima) while (ima->packedfiles.last) { ImagePackedFile *imapf = ima->packedfiles.last; if (imapf->packedfile) { - freePackedFile(imapf->packedfile); + BKE_packedfile_free(imapf->packedfile); } BLI_remlink(&ima->packedfiles, imapf); MEM_freeN(imapf); @@ -377,7 +377,7 @@ static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src) STRNCPY(imapf_dst->filepath, imapf_src->filepath); if (imapf_src->packedfile) { - imapf_dst->packedfile = dupPackedFile(imapf_src->packedfile); + imapf_dst->packedfile = BKE_packedfile_duplicate(imapf_src->packedfile); } BLI_addtail(lb_dst, imapf_dst); @@ -838,7 +838,7 @@ 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 = newPackedFile(reports, ima->name, basepath); + imapf->packedfile = BKE_packedfile_new(reports, ima->name, basepath); if (imapf->packedfile) { STRNCPY(imapf->filepath, ima->name); } @@ -852,7 +852,7 @@ void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath) ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image packed file"); BLI_addtail(&ima->packedfiles, imapf); - imapf->packedfile = newPackedFile(reports, iv->filepath, basepath); + imapf->packedfile = BKE_packedfile_new(reports, iv->filepath, basepath); if (imapf->packedfile) { STRNCPY(imapf->filepath, iv->filepath); } @@ -876,7 +876,7 @@ void BKE_image_packfiles_from_mem(ReportList *reports, else { ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), __func__); BLI_addtail(&ima->packedfiles, imapf); - imapf->packedfile = newPackedFileMemory(data, data_len); + imapf->packedfile = BKE_packedfile_new_from_memory(data, data_len); STRNCPY(imapf->filepath, ima->name); } } @@ -3241,9 +3241,9 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) ImagePackedFile *imapf; for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) { PackedFile *pf; - pf = newPackedFile(NULL, imapf->filepath, ID_BLEND_PATH(bmain, &ima->id)); + pf = BKE_packedfile_new(NULL, imapf->filepath, ID_BLEND_PATH(bmain, &ima->id)); if (pf) { - freePackedFile(imapf->packedfile); + BKE_packedfile_free(imapf->packedfile); imapf->packedfile = pf; } else { @@ -4014,7 +4014,8 @@ static ImBuf *load_image_single(Image *ima, BLI_addtail(&ima->packedfiles, imapf); STRNCPY(imapf->filepath, filepath); - imapf->packedfile = newPackedFile(NULL, filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); + imapf->packedfile = BKE_packedfile_new( + NULL, filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); } } } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index ab5ae7be5a6..7e8128945e7 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1502,7 +1502,7 @@ void *BKE_libblock_copy_for_localize(const ID *id) void BKE_library_free(Library *lib) { if (lib->packedfile) { - freePackedFile(lib->packedfile); + BKE_packedfile_free(lib->packedfile); } } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index dd91878a15b..d4deb6ee7e5 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -49,7 +49,7 @@ #include "BKE_report.h" #include "BKE_sound.h" -int seekPackedFile(PackedFile *pf, int offset, int whence) +int BKE_packedfile_seek(PackedFile *pf, int offset, int whence) { int oldseek = -1, seek = 0; @@ -81,12 +81,12 @@ int seekPackedFile(PackedFile *pf, int offset, int whence) return (oldseek); } -void rewindPackedFile(PackedFile *pf) +void BKE_packedfile_rewind(PackedFile *pf) { - seekPackedFile(pf, 0, SEEK_SET); + BKE_packedfile_seek(pf, 0, SEEK_SET); } -int readPackedFile(PackedFile *pf, void *data, int size) +int BKE_packedfile_read(PackedFile *pf, void *data, int size) { if ((pf != NULL) && (size >= 0) && (data != NULL)) { if (size + pf->seek > pf->size) { @@ -109,7 +109,7 @@ int readPackedFile(PackedFile *pf, void *data, int size) return (size); } -int countPackedFiles(Main *bmain) +int BKE_packedfile_count_all(Main *bmain) { Image *ima; VFont *vf; @@ -138,18 +138,18 @@ int countPackedFiles(Main *bmain) return count; } -void freePackedFile(PackedFile *pf) +void BKE_packedfile_free(PackedFile *pf) { if (pf) { MEM_freeN(pf->data); MEM_freeN(pf); } else { - printf("freePackedFile: Trying to free a NULL pointer\n"); + printf("BKE_packedfile_free: Trying to free a NULL pointer\n"); } } -PackedFile *dupPackedFile(const PackedFile *pf_src) +PackedFile *BKE_packedfile_duplicate(const PackedFile *pf_src) { PackedFile *pf_dst; @@ -159,7 +159,7 @@ PackedFile *dupPackedFile(const PackedFile *pf_src) return pf_dst; } -PackedFile *newPackedFileMemory(void *mem, int memlen) +PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen) { PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile"); pf->data = mem; @@ -168,7 +168,7 @@ PackedFile *newPackedFileMemory(void *mem, int memlen) return pf; } -PackedFile *newPackedFile(ReportList *reports, const char *filename, const char *basepath) +PackedFile *BKE_packedfile_new(ReportList *reports, const char *filename, const char *basepath) { PackedFile *pf = NULL; int file, filelen; @@ -207,7 +207,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char data = MEM_mallocN(filelen, "packFile"); } if (read(file, data, filelen) == filelen) { - pf = newPackedFileMemory(data, filelen); + pf = BKE_packedfile_new_from_memory(data, filelen); } else { MEM_freeN(data); @@ -222,7 +222,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char } /* no libraries for now */ -void packAll(Main *bmain, ReportList *reports, bool verbose) +void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose) { Image *ima; VFont *vfont; @@ -247,14 +247,14 @@ void packAll(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 = newPackedFile(reports, vfont->name, BKE_main_blendfile_path(bmain)); + vfont->packedfile = BKE_packedfile_new(reports, vfont->name, 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 = newPackedFile(reports, sound->name, BKE_main_blendfile_path(bmain)); + sound->packedfile = BKE_packedfile_new(reports, sound->name, BKE_main_blendfile_path(bmain)); tot++; } } @@ -267,11 +267,11 @@ void packAll(Main *bmain, ReportList *reports, bool verbose) } } -int writePackedFile(ReportList *reports, - const char *ref_file_name, - const char *filename, - PackedFile *pf, - const bool guimode) +int BKE_packedfile_write_to_file(ReportList *reports, + const char *ref_file_name, + const char *filename, + PackedFile *pf, + const bool guimode) { int file, number; int ret_value = RET_OK; @@ -349,7 +349,7 @@ int writePackedFile(ReportList *reports, * - PF_DIFFERENT: the packed file and original file differ * - PF_NOFILE: the original file doesn't exist */ -int checkPackedFile(const char *ref_file_name, const char *filename, PackedFile *pf) +int BKE_packedfile_compare_to_file(const char *ref_file_name, const char *filename, PackedFile *pf) { BLI_stat_t st; int ret_val, i, len, file; @@ -402,7 +402,8 @@ int checkPackedFile(const char *ref_file_name, const char *filename, PackedFile } /** - * unpackFile() looks at the existing files (abs_name, local_name) and a packed file. + * #BKE_packedfile_unpack_to_file() looks at the existing files (abs_name, local_name) + * and a packed file. * * It returns a char *to the existing file name / new file name or NULL when * there was an error or when the user decides to cancel the operation. @@ -410,12 +411,12 @@ int checkPackedFile(const char *ref_file_name, const char *filename, PackedFile * \warning 'abs_name' may be relative still! (use a "//" prefix) * be sure to run #BLI_path_abs on it first. */ -char *unpackFile(ReportList *reports, - const char *ref_file_name, - const char *abs_name, - const char *local_name, - PackedFile *pf, - int how) +char *BKE_packedfile_unpack_to_file(ReportList *reports, + const char *ref_file_name, + const char *abs_name, + const char *local_name, + PackedFile *pf, + int how) { char *newname = NULL; const char *temp = NULL; @@ -443,7 +444,7 @@ char *unpackFile(ReportList *reports, ATTR_FALLTHROUGH; } case PF_WRITE_LOCAL: - if (writePackedFile(reports, ref_file_name, local_name, pf, 1) == RET_OK) { + if (BKE_packedfile_write_to_file(reports, ref_file_name, local_name, pf, 1) == RET_OK) { temp = local_name; } break; @@ -463,12 +464,12 @@ char *unpackFile(ReportList *reports, ATTR_FALLTHROUGH; } case PF_WRITE_ORIGINAL: - if (writePackedFile(reports, ref_file_name, abs_name, pf, 1) == RET_OK) { + if (BKE_packedfile_write_to_file(reports, ref_file_name, abs_name, pf, 1) == RET_OK) { temp = abs_name; } break; default: - printf("unpackFile: unknown return_value %d\n", how); + printf("BKE_packedfile_unpack_to_file: unknown return_value %d\n", how); break; } @@ -525,7 +526,7 @@ static void unpack_generate_paths(const char *name, } } -int unpackVFont(Main *bmain, ReportList *reports, VFont *vfont, int how) +int BKE_packedfile_unpack_vfont(Main *bmain, ReportList *reports, VFont *vfont, int how) { char localname[FILE_MAX], absname[FILE_MAX]; char *newname; @@ -534,11 +535,11 @@ int unpackVFont(Main *bmain, ReportList *reports, VFont *vfont, int how) if (vfont != NULL) { unpack_generate_paths( vfont->name, (ID *)vfont, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile( + newname = BKE_packedfile_unpack_to_file( reports, BKE_main_blendfile_path(bmain), absname, localname, vfont->packedfile, how); if (newname != NULL) { ret_value = RET_OK; - freePackedFile(vfont->packedfile); + BKE_packedfile_free(vfont->packedfile); vfont->packedfile = NULL; BLI_strncpy(vfont->name, newname, sizeof(vfont->name)); MEM_freeN(newname); @@ -548,7 +549,7 @@ int unpackVFont(Main *bmain, ReportList *reports, VFont *vfont, int how) return (ret_value); } -int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) +int BKE_packedfile_unpack_sound(Main *bmain, ReportList *reports, bSound *sound, int how) { char localname[FILE_MAX], absname[FILE_MAX]; char *newname; @@ -557,13 +558,13 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) if (sound != NULL) { unpack_generate_paths( sound->name, (ID *)sound, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile( + 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)); MEM_freeN(newname); - freePackedFile(sound->packedfile); + BKE_packedfile_free(sound->packedfile); sound->packedfile = NULL; BKE_sound_load(bmain, sound); @@ -575,7 +576,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) return (ret_value); } -int unpackImage(Main *bmain, ReportList *reports, Image *ima, int how) +int BKE_packedfile_unpack_image(Main *bmain, ReportList *reports, Image *ima, int how) { int ret_value = RET_ERROR; @@ -587,14 +588,14 @@ int unpackImage(Main *bmain, ReportList *reports, Image *ima, int how) unpack_generate_paths( imapf->filepath, (ID *)ima, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile( + newname = BKE_packedfile_unpack_to_file( reports, BKE_main_blendfile_path(bmain), absname, localname, imapf->packedfile, how); if (newname != NULL) { ImageView *iv; ret_value = ret_value == RET_ERROR ? RET_ERROR : RET_OK; - freePackedFile(imapf->packedfile); + BKE_packedfile_free(imapf->packedfile); imapf->packedfile = NULL; /* update the new corresponding view filepath */ @@ -625,7 +626,7 @@ int unpackImage(Main *bmain, ReportList *reports, Image *ima, int how) return (ret_value); } -int unpackLibraries(Main *bmain, ReportList *reports) +int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports) { Library *lib; char *newname; @@ -634,18 +635,18 @@ int unpackLibraries(Main *bmain, ReportList *reports) for (lib = bmain->libraries.first; lib; lib = lib->id.next) { if (lib->packedfile && lib->name[0]) { - newname = unpackFile(reports, - BKE_main_blendfile_path(bmain), - lib->filepath, - lib->filepath, - lib->packedfile, - PF_WRITE_ORIGINAL); + newname = BKE_packedfile_unpack_to_file(reports, + BKE_main_blendfile_path(bmain), + lib->filepath, + lib->filepath, + lib->packedfile, + PF_WRITE_ORIGINAL); if (newname != NULL) { ret_value = RET_OK; printf("Unpacked .blend library: %s\n", newname); - freePackedFile(lib->packedfile); + BKE_packedfile_free(lib->packedfile); lib->packedfile = NULL; MEM_freeN(newname); @@ -656,7 +657,7 @@ int unpackLibraries(Main *bmain, ReportList *reports) return (ret_value); } -void packLibraries(Main *bmain, ReportList *reports) +void BKE_packedfile_pack_all_libraries(Main *bmain, ReportList *reports) { Library *lib; @@ -674,12 +675,12 @@ void packLibraries(Main *bmain, ReportList *reports) for (lib = bmain->libraries.first; lib; lib = lib->id.next) { if (lib->packedfile == NULL) { - lib->packedfile = newPackedFile(reports, lib->name, BKE_main_blendfile_path(bmain)); + lib->packedfile = BKE_packedfile_new(reports, lib->name, BKE_main_blendfile_path(bmain)); } } } -void unpackAll(Main *bmain, ReportList *reports, int how) +void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, int how) { Image *ima; VFont *vf; @@ -687,25 +688,25 @@ void unpackAll(Main *bmain, ReportList *reports, int how) for (ima = bmain->images.first; ima; ima = ima->id.next) { if (BKE_image_has_packedfile(ima)) { - unpackImage(bmain, reports, ima, how); + BKE_packedfile_unpack_image(bmain, reports, ima, how); } } for (vf = bmain->fonts.first; vf; vf = vf->id.next) { if (vf->packedfile) { - unpackVFont(bmain, reports, vf, how); + BKE_packedfile_unpack_vfont(bmain, reports, vf, how); } } for (sound = bmain->sounds.first; sound; sound = sound->id.next) { if (sound->packedfile) { - unpackSound(bmain, reports, sound, how); + BKE_packedfile_unpack_sound(bmain, reports, sound, how); } } } /* ID should be not NULL, return 1 if there's a packed file */ -bool BKE_pack_check(ID *id) +bool BKE_packedfile_id_check(ID *id) { switch (GS(id->name)) { case ID_IM: { @@ -731,27 +732,27 @@ bool BKE_pack_check(ID *id) } /* ID should be not NULL */ -void BKE_unpack_id(Main *bmain, ID *id, ReportList *reports, int how) +void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, int how) { switch (GS(id->name)) { case ID_IM: { Image *ima = (Image *)id; if (BKE_image_has_packedfile(ima)) { - unpackImage(bmain, reports, ima, how); + BKE_packedfile_unpack_image(bmain, reports, ima, how); } break; } case ID_VF: { VFont *vf = (VFont *)id; if (vf->packedfile) { - unpackVFont(bmain, reports, vf, how); + BKE_packedfile_unpack_vfont(bmain, reports, vf, how); } break; } case ID_SO: { bSound *snd = (bSound *)id; if (snd->packedfile) { - unpackSound(bmain, reports, snd, how); + BKE_packedfile_unpack_sound(bmain, reports, snd, how); } break; } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index ad26314e877..1722b888d28 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -170,7 +170,7 @@ void BKE_sound_free(bSound *sound) /* No animdata here. */ if (sound->packedfile) { - freePackedFile(sound->packedfile); + BKE_packedfile_free(sound->packedfile); sound->packedfile = NULL; } @@ -211,7 +211,7 @@ void BKE_sound_copy_data(Main *UNUSED(bmain), sound_dst->newpackedfile = NULL; if (sound_dst->packedfile) { - sound_dst->packedfile = dupPackedFile(sound_dst->packedfile); + sound_dst->packedfile = BKE_packedfile_duplicate(sound_dst->packedfile); } BKE_sound_reset_runtime(sound_dst); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 5d3ef5c625e..1fc1af9815f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -952,7 +952,7 @@ static void template_ID(bContext *C, /* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack. * Only for images, sound and fonts */ - if (id && BKE_pack_check(id)) { + if (id && BKE_packedfile_id_check(id)) { but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_unpack_item", diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 30ddd8c7d33..f4191f87df6 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -765,7 +765,8 @@ static int sound_pack_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - sound->packedfile = newPackedFile(op->reports, sound->name, ID_BLEND_PATH(bmain, &sound->id)); + sound->packedfile = BKE_packedfile_new( + op->reports, sound->name, ID_BLEND_PATH(bmain, &sound->id)); BKE_sound_load(bmain, sound); return OPERATOR_FINISHED; @@ -811,7 +812,7 @@ static int sound_unpack_exec(bContext *C, wmOperator *op) "AutoPack is enabled, so image will be packed again on file save"); } - unpackSound(bmain, op->reports, sound, method); + BKE_packedfile_unpack_sound(bmain, op->reports, sound, method); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 96eaa89d175..b79ed1c83c4 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1391,7 +1391,7 @@ static int image_open_exec(bContext *C, wmOperator *op) BKE_image_init_imageuser(ima, iuser); } - /* XXX unpackImage frees image buffers */ + /* XXX BKE_packedfile_unpack_image frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), bmain); BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_RELOAD); @@ -1601,7 +1601,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) sima->image->source = IMA_SRC_FILE; } - /* XXX unpackImage frees image buffers */ + /* XXX BKE_packedfile_unpack_image frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); BKE_icon_changed(BKE_icon_id_ensure(&sima->image->id)); @@ -2401,7 +2401,7 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - /* XXX unpackImage frees image buffers */ + /* XXX BKE_packedfile_unpack_image frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_RELOAD); @@ -2859,10 +2859,10 @@ static int image_unpack_exec(bContext *C, wmOperator *op) "AutoPack is enabled, so image will be packed again on file save"); } - /* XXX unpackImage frees image buffers */ + /* XXX BKE_packedfile_unpack_image frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - unpackImage(CTX_data_main(C), op->reports, ima, method); + BKE_packedfile_unpack_image(CTX_data_main(C), op->reports, ima, method); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index bf43e493cc5..6460c3db8c2 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -65,7 +65,7 @@ static int pack_libraries_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - packLibraries(bmain, op->reports); + BKE_packedfile_pack_all_libraries(bmain, op->reports); return OPERATOR_FINISHED; } @@ -88,7 +88,7 @@ static int unpack_libraries_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - unpackLibraries(bmain, op->reports); + BKE_packedfile_unpack_all_libraries(bmain, op->reports); return OPERATOR_FINISHED; } @@ -124,7 +124,7 @@ static int autopack_toggle_exec(bContext *C, wmOperator *op) G.fileflags &= ~G_FILE_AUTOPACK; } else { - packAll(bmain, op->reports, true); + BKE_packedfile_pack_all(bmain, op->reports, true); G.fileflags |= G_FILE_AUTOPACK; } @@ -151,7 +151,7 @@ static int pack_all_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - packAll(bmain, op->reports, true); + BKE_packedfile_pack_all(bmain, op->reports, true); return OPERATOR_FINISHED; } @@ -221,7 +221,7 @@ static int unpack_all_exec(bContext *C, wmOperator *op) int method = RNA_enum_get(op->ptr, "method"); if (method != PF_KEEP) { - unpackAll(bmain, op->reports, method); /* XXX PF_ASK can't work here */ + BKE_packedfile_unpack_all(bmain, op->reports, method); /* XXX PF_ASK can't work here */ } G.fileflags &= ~G_FILE_AUTOPACK; @@ -236,7 +236,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( char title[64]; int count = 0; - count = countPackedFiles(bmain); + count = BKE_packedfile_count_all(bmain); if (!count) { BKE_report(op->reports, RPT_WARNING, "No packed files to unpack"); @@ -321,7 +321,7 @@ static int unpack_item_exec(bContext *C, wmOperator *op) } if (method != PF_KEEP) { - BKE_unpack_id(bmain, id, op->reports, method); /* XXX PF_ASK can't work here */ + BKE_packedfile_id_unpack(bmain, id, op->reports, method); /* XXX PF_ASK can't work here */ } G.fileflags &= ~G_FILE_AUTOPACK; diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 1ee8ff6966c..fd0f7fd47c4 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -326,7 +326,7 @@ void unpack_menu(bContext *C, BLI_split_file_part(abs_name, fi, sizeof(fi)); BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi); if (!STREQ(abs_name, local_name)) { - switch (checkPackedFile(BKE_main_blendfile_path(bmain), local_name, pf)) { + switch (BKE_packedfile_compare_to_file(BKE_main_blendfile_path(bmain), local_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), TIP_("Create %s"), local_name); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); @@ -359,7 +359,7 @@ void unpack_menu(bContext *C, } } - switch (checkPackedFile(BKE_main_blendfile_path(bmain), abs_name, pf)) { + switch (BKE_packedfile_compare_to_file(BKE_main_blendfile_path(bmain), abs_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), TIP_("Create %s"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 933dae70457..0db099e3e1d 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -55,7 +55,7 @@ static void rna_ImagePackedFile_save(ImagePackedFile *imapf, Main *bmain, ReportList *reports) { - if (writePackedFile( + if (BKE_packedfile_write_to_file( reports, BKE_main_blendfile_path(bmain), imapf->filepath, imapf->packedfile, 0) != RET_OK) { BKE_reportf(reports, RPT_ERROR, "Could not save packed file to disk as '%s'", imapf->filepath); @@ -179,7 +179,7 @@ static void rna_Image_unpack(Image *image, Main *bmain, ReportList *reports, int } else { /* reports its own error on failure */ - unpackImage(bmain, reports, image, method); + BKE_packedfile_unpack_image(bmain, reports, image, method); } } diff --git a/source/blender/makesrna/intern/rna_sound_api.c b/source/blender/makesrna/intern/rna_sound_api.c index f172c659900..1482a08b893 100644 --- a/source/blender/makesrna/intern/rna_sound_api.c +++ b/source/blender/makesrna/intern/rna_sound_api.c @@ -34,7 +34,7 @@ static void rna_Sound_pack(bSound *sound, Main *bmain, ReportList *reports) { - sound->packedfile = newPackedFile(reports, sound->name, ID_BLEND_PATH(bmain, &sound->id)); + sound->packedfile = BKE_packedfile_new(reports, sound->name, ID_BLEND_PATH(bmain, &sound->id)); } static void rna_Sound_unpack(bSound *sound, Main *bmain, ReportList *reports, int method) @@ -44,7 +44,7 @@ static void rna_Sound_unpack(bSound *sound, Main *bmain, ReportList *reports, in } else { /* reports its own error on failure */ - unpackSound(bmain, reports, sound, method); + BKE_packedfile_unpack_sound(bmain, reports, sound, method); } } diff --git a/source/blender/makesrna/intern/rna_vfont_api.c b/source/blender/makesrna/intern/rna_vfont_api.c index f35a764b1b0..bdd73bbb3a6 100644 --- a/source/blender/makesrna/intern/rna_vfont_api.c +++ b/source/blender/makesrna/intern/rna_vfont_api.c @@ -34,7 +34,7 @@ static void rna_VectorFont_pack(VFont *vfont, Main *bmain, ReportList *reports) { - vfont->packedfile = newPackedFile(reports, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); + vfont->packedfile = BKE_packedfile_new(reports, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); } static void rna_VectorFont_unpack(VFont *vfont, Main *bmain, ReportList *reports, int method) @@ -44,7 +44,7 @@ static void rna_VectorFont_unpack(VFont *vfont, Main *bmain, ReportList *reports } else { /* reports its own error on failure */ - unpackVFont(bmain, reports, vfont, method); + BKE_packedfile_unpack_vfont(bmain, reports, vfont, method); } } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index fe93e39b085..49b13da6b21 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1376,7 +1376,7 @@ static bool wm_file_write(bContext *C, const char *filepath, int fileflags, Repo /* operator now handles overwrite checks */ if (G.fileflags & G_FILE_AUTOPACK) { - packAll(bmain, reports, false); + BKE_packedfile_pack_all(bmain, reports, false); } /* don't forget not to return without! */ -- cgit v1.2.3