diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_packedFile.h | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/packedFile.c | 24 | ||||
-rw-r--r-- | source/blender/editors/util/ed_util.c | 12 |
3 files changed, 28 insertions, 24 deletions
diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index 00a241c259a..ab8d07d18e0 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -33,11 +33,13 @@ struct ReportList; struct VFont; struct bSound; -enum ePF_FileStatus { - PF_EQUAL = 0, - PF_DIFFERS = 1, - PF_NOFILE = 2, +enum ePF_FileCompare { + PF_CMP_EQUAL = 0, + PF_CMP_DIFFERS = 1, + PF_CMP_NOFILE = 2, +}; +enum ePF_FileStatus { PF_WRITE_ORIGINAL = 3, PF_WRITE_LOCAL = 4, PF_USE_LOCAL = 5, @@ -94,9 +96,9 @@ void BKE_packedfile_free(struct PackedFile *pf); /* info */ 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); +enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, + const char *filename, + struct PackedFile *pf); /* read */ int BKE_packedfile_seek(struct PackedFile *pf, int offset, int whence); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 966bee03b78..8e647757b40 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -349,10 +349,12 @@ int BKE_packedfile_write_to_file(ReportList *reports, * - PF_DIFFERENT: the packed file and original file differ * - PF_NOFILE: the original file doesn't exist */ -int BKE_packedfile_compare_to_file(const char *ref_file_name, const char *filename, PackedFile *pf) +enum ePF_FileCompare 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; + enum ePF_FileCompare ret_val; char buf[4096]; char name[FILE_MAX]; @@ -360,35 +362,35 @@ int BKE_packedfile_compare_to_file(const char *ref_file_name, const char *filena BLI_path_abs(name, ref_file_name); if (BLI_stat(name, &st) == -1) { - ret_val = PF_NOFILE; + ret_val = PF_CMP_NOFILE; } else if (st.st_size != pf->size) { - ret_val = PF_DIFFERS; + ret_val = PF_CMP_DIFFERS; } else { /* we'll have to compare the two... */ - file = BLI_open(name, O_BINARY | O_RDONLY, 0); + const int file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file == -1) { - ret_val = PF_NOFILE; + ret_val = PF_CMP_NOFILE; } else { - ret_val = PF_EQUAL; + ret_val = PF_CMP_EQUAL; - for (i = 0; i < pf->size; i += sizeof(buf)) { - len = pf->size - i; + for (int i = 0; i < pf->size; i += sizeof(buf)) { + int len = pf->size - i; if (len > sizeof(buf)) { len = sizeof(buf); } if (read(file, buf, len) != len) { /* read error ... */ - ret_val = PF_DIFFERS; + ret_val = PF_CMP_DIFFERS; break; } else { if (memcmp(buf, ((char *)pf->data) + i, len)) { - ret_val = PF_DIFFERS; + ret_val = PF_CMP_DIFFERS; break; } } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index fd0f7fd47c4..c1b6a7b42b2 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -327,14 +327,14 @@ void unpack_menu(bContext *C, BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi); if (!STREQ(abs_name, local_name)) { switch (BKE_packedfile_compare_to_file(BKE_main_blendfile_path(bmain), local_name, pf)) { - case PF_NOFILE: + case PF_CMP_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); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; - case PF_EQUAL: + case PF_CMP_EQUAL: BLI_snprintf(line, sizeof(line), TIP_("Use %s (identical)"), local_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); @@ -342,7 +342,7 @@ void unpack_menu(bContext *C, RNA_string_set(&props_ptr, "id", id_name); break; - case PF_DIFFERS: + case PF_CMP_DIFFERS: BLI_snprintf(line, sizeof(line), TIP_("Use %s (differs)"), local_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); @@ -360,21 +360,21 @@ void unpack_menu(bContext *C, } switch (BKE_packedfile_compare_to_file(BKE_main_blendfile_path(bmain), abs_name, pf)) { - case PF_NOFILE: + case PF_CMP_NOFILE: BLI_snprintf(line, sizeof(line), TIP_("Create %s"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; - case PF_EQUAL: + case PF_CMP_EQUAL: BLI_snprintf(line, sizeof(line), TIP_("Use %s (identical)"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; - case PF_DIFFERS: + case PF_CMP_DIFFERS: BLI_snprintf(line, sizeof(line), TIP_("Use %s (differs)"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); |