New -find actions "rm" and "rm_r", silenced comparison results with -update*
This commit is contained in:
@ -2478,6 +2478,7 @@ int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag)
|
||||
bit1= remove empty directory: rmdir
|
||||
bit2= recursion: do not reassure in mode 2 "tree"
|
||||
bit3= this is for overwriting and not for plain removal
|
||||
bit4= count deleted files in xorriso->pacifier_count
|
||||
@return <=0 = error
|
||||
1 = removed simple node
|
||||
2 = removed directory or tree
|
||||
@ -2572,7 +2573,7 @@ cannot_create_iter:;
|
||||
if(Xorriso_much_too_long(xorriso, pl+1+strlen(name), 0)<=0)
|
||||
{ret= 0; goto rm_r_problem_handler;}
|
||||
strcpy(sub_name, name);
|
||||
ret= Xorriso_rmi(xorriso, iter, sub_path, (flag&(1|2|8))|4);
|
||||
ret= Xorriso_rmi(xorriso, iter, sub_path, (flag&(1|2|8|16))|4);
|
||||
if(ret==3 || ret<=0 || xorriso->request_to_abort) {
|
||||
rm_r_problem_handler:;
|
||||
not_removed= 1;
|
||||
@ -2691,6 +2692,8 @@ dir_not_removed:;
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
||||
ret= -1; goto ex;
|
||||
}
|
||||
if(flag&16)
|
||||
xorriso->pacifier_count++;
|
||||
xorriso->volset_change_pending= 1;
|
||||
ret= 1+!!is_dir;
|
||||
ex:;
|
||||
@ -3782,13 +3785,14 @@ int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t,
|
||||
|
||||
|
||||
/* @param flag bit0= not a command parameter (directory iteration or recursion)
|
||||
bit1= do not count deleted files with rm and rm_r
|
||||
*/
|
||||
int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
IsoDirIter *boss_iter, off_t boss_mem,
|
||||
char *abs_path, char *show_path,
|
||||
IsoNode *node, int depth, int flag)
|
||||
{
|
||||
int ret= 0, type, action= 0;
|
||||
int ret= 0, type, action= 0, hflag;
|
||||
uid_t user= 0;
|
||||
gid_t group= 0;
|
||||
time_t date= 0;
|
||||
@ -3802,12 +3806,16 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
if(action<0)
|
||||
action= 0;
|
||||
|
||||
if(action==1) {
|
||||
/* >>> rm */;
|
||||
} else if(action==2) {
|
||||
|
||||
/* >>> rm_r */;
|
||||
|
||||
hflag= 16*!(flag&2);
|
||||
if(action==1) { /* rm (including rmdir) */
|
||||
ret= Xorriso_fake_stbuf(xorriso, abs_path, &dir_stbuf, &node, 1);
|
||||
if(ret>0) {
|
||||
if(S_ISDIR(dir_stbuf.st_mode))
|
||||
hflag= 2;
|
||||
ret= Xorriso_rmi(xorriso, boss_iter, abs_path, hflag);
|
||||
}
|
||||
} else if(action==2) { /* rm_r */
|
||||
ret= Xorriso_rmi(xorriso, boss_iter, abs_path, 1|hflag);
|
||||
} else if(action==3) {
|
||||
|
||||
/* >>> mv target */;
|
||||
@ -3864,6 +3872,7 @@ int Xorriso__node_lba_cmp(const void *node1, const void *node2)
|
||||
provides the memory of proper type.
|
||||
@param flag bit0= initialize iteration
|
||||
bit1= action needs full freedom of object manipulation
|
||||
bit2= action needs LBA sorted iteration
|
||||
bit31= end iteration (mandatory !)
|
||||
*/
|
||||
int Xorriso_findi_iter(struct XorrisO *xorriso, IsoDir *dir_node, off_t *mem,
|
||||
@ -3887,7 +3896,7 @@ cannot_iter:;
|
||||
Xorriso_cannot_create_iter(xorriso, ret, 0);
|
||||
return(-1);
|
||||
}
|
||||
if(flag&2) {
|
||||
if((flag&2)|(flag&4)) {
|
||||
/* copy list of nodes and prepare soft iterator */
|
||||
*node_count= 0;
|
||||
while(iso_dir_iter_next(*iter, &node) == 1)
|
||||
@ -3928,7 +3937,7 @@ cannot_iter:;
|
||||
*iter= NULL;
|
||||
*node_count= *node_idx;
|
||||
*node_idx= 0;
|
||||
if(*node_count>1)
|
||||
if((flag&4) && *node_count>1)
|
||||
qsort(*node_array, *node_count, sizeof(IsoNode *),
|
||||
Xorriso__node_lba_cmp);
|
||||
}
|
||||
@ -3966,31 +3975,27 @@ cannot_iter:;
|
||||
|
||||
|
||||
/* @param flag bit0= recursion
|
||||
bit1= do not count deleted files with rm and rm_r
|
||||
*/
|
||||
int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
void *boss_iter, off_t boss_mem,
|
||||
void *dir_node_generic, char *dir_path,
|
||||
struct stat *dir_stbuf, int depth, int flag)
|
||||
{
|
||||
int ret, action= 0;
|
||||
int ret, action= 0, hflag;
|
||||
IsoDirIter *iter= NULL;
|
||||
IsoDir *dir_node= NULL;
|
||||
IsoNode *node, *iso_node;
|
||||
IsoImage *volume;
|
||||
struct stat stbuf;
|
||||
char *name;
|
||||
off_t mem;
|
||||
IsoNode **node_array= NULL;
|
||||
int node_count, node_idx;
|
||||
#ifdef Xorriso_fat_local_meM
|
||||
char path[SfileadrL], abs_path[SfileadrL];
|
||||
#else /* Xorriso_fat_local_meM */
|
||||
char *path= NULL, *abs_path= NULL;
|
||||
off_t mem;
|
||||
|
||||
#define Xorriso_findi_new_iteR yes
|
||||
|
||||
#ifdef Xorriso_findi_new_iteR
|
||||
IsoNode **node_array= NULL;
|
||||
int node_count, node_idx;
|
||||
#endif
|
||||
|
||||
path= malloc(SfileadrL);
|
||||
abs_path= malloc(SfileadrL);
|
||||
@ -4033,7 +4038,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
ret= Xorriso_findi_action(xorriso, job,
|
||||
(IsoDirIter *) boss_iter, boss_mem,
|
||||
path, dir_path, (IsoNode *) dir_node, depth,
|
||||
flag&1);
|
||||
flag&(1|2));
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
}
|
||||
@ -4041,12 +4046,15 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
if(!LIBISO_ISDIR((IsoNode *) dir_node))
|
||||
{ret= 2; goto ex;}
|
||||
|
||||
#ifdef Xorriso_findi_new_iteR
|
||||
|
||||
mem= boss_mem;
|
||||
hflag= 1;
|
||||
if(action==1 || action==2 || action==3 || action==14)
|
||||
hflag|= 2; /* need freedom to manipulate image */
|
||||
if(action==14 || action==17)
|
||||
hflag|= 4; /* need LBA sorted iteration for good data reading performance */
|
||||
ret= Xorriso_findi_iter(xorriso, dir_node, &mem,
|
||||
&iter, &node_array, &node_count, &node_idx,
|
||||
&node, 1|((action==14 || action==17)<<1));
|
||||
&node, hflag);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
while(1) {
|
||||
@ -4056,18 +4064,6 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
goto ex;
|
||||
if(ret==0 || xorriso->request_to_abort)
|
||||
break;
|
||||
|
||||
#else
|
||||
|
||||
ret= iso_dir_get_children(dir_node, &iter);
|
||||
if(ret<0) {
|
||||
Xorriso_cannot_create_iter(xorriso, ret, 0);
|
||||
{ret= -1; goto ex;}
|
||||
}
|
||||
while(iso_dir_iter_next(iter, &node) == 1 && !xorriso->request_to_abort) {
|
||||
|
||||
#endif /* ! Xorriso_findi_new_iteR */
|
||||
|
||||
name= (char *) iso_node_get_name(node);
|
||||
ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4);
|
||||
if(ret<=0)
|
||||
@ -4086,7 +4082,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
ret= Xorriso_findi_action(xorriso, job, iter, mem,
|
||||
abs_path, path, node, depth, 1);
|
||||
abs_path, path, node, depth, 1|(flag&2));
|
||||
if(ret<=0) {
|
||||
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
|
||||
goto ex;
|
||||
|
Reference in New Issue
Block a user