Cleanup: split enum types, use PF_CMP prefix
This commit is contained in:
parent
1357dd7d3c
commit
ad16af7a7e
Notes:
blender-bot
2023-02-14 06:19:41 +01:00
Referenced by issue #66555, Handler render init ignores output placeholders
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue