diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_packedFile.h | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/packedFile.c | 24 |
2 files changed, 22 insertions, 18 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; } } |