Added new action "compare" to -find
This commit is contained in:
@ -2392,6 +2392,7 @@ struct FindjoB {
|
||||
11= chmod_r mode_and mode_or
|
||||
12= alter_date_r type date
|
||||
13= find
|
||||
14= compare disk_equivalent_of_start_path
|
||||
*/
|
||||
int action;
|
||||
char *target;
|
||||
@ -2470,6 +2471,13 @@ int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag)
|
||||
}
|
||||
|
||||
|
||||
int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag)
|
||||
{
|
||||
*start_path= o->start_path;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag)
|
||||
{
|
||||
char regexpr[2*SfileadrL+2];
|
||||
@ -4339,8 +4347,8 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
|
||||
wanted= sizeof(buf2);
|
||||
|
||||
/*
|
||||
#define Libisofs_data_read_as_posiX yes
|
||||
*/
|
||||
#define Libisofs_data_read_as_posiX yes
|
||||
#ifndef Libisofs_data_read_as_posiX
|
||||
/* This functions guarantees to deliver full buffers but fails on
|
||||
oversized read requests. */
|
||||
@ -4423,6 +4431,23 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_find_compare(struct XorrisO *xorriso, char *iso_path,
|
||||
char *iso_prefix, char *disk_prefix, int flag)
|
||||
{
|
||||
int ret;
|
||||
char disk_path[SfileadrL], adrc[SfileadrL];
|
||||
|
||||
if(strncmp(iso_path, iso_prefix, strlen(iso_prefix))!=0)
|
||||
return(-1);
|
||||
if(strlen(disk_prefix)+strlen(iso_path)-strlen(iso_prefix)>=SfileadrL)
|
||||
return(-1);
|
||||
strcpy(adrc, iso_path+strlen(iso_prefix));
|
||||
sprintf(disk_path, "%s%s%s", disk_prefix, (adrc[0]=='/' ? "" : "/"), adrc);
|
||||
ret= Xorriso_compare_2_files(xorriso, disk_path, iso_path, adrc, 2|(1<<29));
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= count result rather than storing it
|
||||
bit1= unexpected change of number is a FATAL event
|
||||
*/
|
||||
@ -8098,12 +8123,13 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
|
||||
{
|
||||
int ret, i, end_idx, type= 0;
|
||||
struct FindjoB *job, *first_job= NULL, *new_job;
|
||||
char *start_path, sfe[5*SfileadrL], *cpt;
|
||||
char *start_path, sfe[5*SfileadrL], *cpt, disk_path_start[SfileadrL];
|
||||
struct stat dir_stbuf;
|
||||
uid_t user= 0;
|
||||
gid_t group= 0;
|
||||
time_t date= 0;
|
||||
mode_t mode_or= 0, mode_and= ~1;
|
||||
double mem_lut= 0.0;
|
||||
|
||||
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
|
||||
start_path= ".";
|
||||
@ -8216,6 +8242,23 @@ not_enough_arguments:;
|
||||
}
|
||||
Findjob_set_action_subjob(job, 13, new_job, 0);
|
||||
job= new_job;
|
||||
|
||||
} else if(strcmp(cpt, "compare")==0) {
|
||||
if(i+1>=end_idx)
|
||||
goto not_enough_arguments;
|
||||
i++;
|
||||
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, argv[i],
|
||||
disk_path_start, 1|2|4);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
Findjob_set_action_target(job, 14, disk_path_start, 0);
|
||||
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, start_path,sfe, 1|2|4);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
Findjob_set_start_path(job, sfe, 0);
|
||||
Xorriso_pacifier_reset(xorriso, 0);
|
||||
mem_lut= xorriso->last_update_time;
|
||||
|
||||
} else {
|
||||
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
|
||||
Text_shellsafe(argv[i], sfe, 0));
|
||||
@ -8244,6 +8287,9 @@ sorry_ex:;
|
||||
else
|
||||
ret= Xorriso_findi(xorriso, first_job, NULL, start_path, &dir_stbuf, 0, 0);
|
||||
ex:;
|
||||
if(mem_lut!=xorriso->last_update_time && mem_lut!=0.0)
|
||||
Xorriso_pacifier_callback(xorriso, "content bytes read",
|
||||
xorriso->pacifier_count, 0, "", 1);
|
||||
Findjob_destroy(&first_job, 0);
|
||||
(*idx)= end_idx;
|
||||
return(ret);
|
||||
|
Reference in New Issue
Block a user