New option update_r, -find actions "update" and "add_missing" (not yet completed)
This commit is contained in:
@ -1776,11 +1776,14 @@ int Xorriso_copy_properties(struct XorrisO *xorriso,
|
||||
}
|
||||
|
||||
|
||||
/** @param flag bit0= mkdir: graft in as empty directory, not as copy from disk
|
||||
bit1= do not report added files
|
||||
@return <=0 = error , 1 = added simple node , 2 = added directory */
|
||||
int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
|
||||
int flag)
|
||||
/* @param boss_iter Opaque handle to be forwarded to actions in ISO image
|
||||
Set to NULL if calling this function from outside ISO world
|
||||
@param flag bit0= mkdir: graft in as empty directory, not as copy from disk
|
||||
bit1= do not report added files
|
||||
@return <=0 = error , 1 = added simple node , 2 = added directory
|
||||
*/
|
||||
int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
|
||||
char *disk_path, char *img_path, int flag)
|
||||
{
|
||||
IsoImage *volume;
|
||||
char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL], sfe2[5*SfileadrL];
|
||||
@ -1895,7 +1898,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
|
||||
/* handle overwrite situation */;
|
||||
if(xorriso->do_overwrite==1 ||
|
||||
(xorriso->do_overwrite==2 && !target_is_dir)) {
|
||||
ret= Xorriso_rmi(xorriso, NULL, path, 1|8);
|
||||
ret= Xorriso_rmi(xorriso, boss_iter, path, 1|8);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
if(ret==3) {
|
||||
@ -2628,12 +2631,25 @@ dir_not_removed:;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Libisofs_iso_dir_iter_remove_repaireD
|
||||
if(boss_iter!=NULL) {
|
||||
ret= iso_dir_iter_remove((IsoDirIter *) boss_iter);
|
||||
if(ret<0)
|
||||
ret= -1;
|
||||
} else
|
||||
ret= iso_node_remove(victim_node);
|
||||
|
||||
#else /* ! Libisofs_iso_dir_iter_remove_repaireD */
|
||||
|
||||
/* Ticket 127: A80301
|
||||
This violates libisofs API prescriptions but works by lucky incident
|
||||
whereas iso_dir_iter_remove() removes the next node to come rather than
|
||||
the most recently returned node.
|
||||
*/
|
||||
ret= iso_node_remove(victim_node);
|
||||
|
||||
#endif /* Libisofs_iso_dir_iter_remove_repaireD */
|
||||
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
if(ret<0) {
|
||||
Xorriso_report_iso_error(xorriso, path, ret, "Cannot remove node", 0,
|
||||
@ -3269,8 +3285,11 @@ ex:;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
|
||||
/* @param boss_iter Opaque handle to be forwarded to actions in ISO image
|
||||
Set to NULL if calling this function from outside ISO world
|
||||
*/
|
||||
int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
|
||||
char *origin, char *dest, int flag)
|
||||
{
|
||||
int ret, ol, dest_ret;
|
||||
char sfe[5*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt;
|
||||
@ -3324,7 +3343,7 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
} else if(dest_ret>0) {
|
||||
ret= Xorriso_rmi(xorriso, NULL, eff_dest, 1|8);
|
||||
ret= Xorriso_rmi(xorriso, boss_iter, eff_dest, 1|8);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
if(ret==3) {
|
||||
@ -3342,7 +3361,7 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
|
||||
cpt= dir_adr+strlen(dir_adr);
|
||||
*cpt= 0;
|
||||
if(dir_adr[0]!=0) {
|
||||
ret= Xorriso_graft_in(xorriso, NULL, dir_adr, 1);
|
||||
ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr, 1);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
}
|
||||
@ -3432,7 +3451,7 @@ int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag)
|
||||
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2);
|
||||
if(ret<0)
|
||||
return(-2);
|
||||
ret= Xorriso_graft_in(xorriso, NULL, eff_path, 1);
|
||||
ret= Xorriso_graft_in(xorriso, NULL, NULL, eff_path, 1);
|
||||
if(ret<=0)
|
||||
return(-2);
|
||||
if(!(flag&1)) {
|
||||
@ -3732,6 +3751,7 @@ int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t,
|
||||
|
||||
|
||||
int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
IsoDirIter *boss_iter,
|
||||
char *abs_path, char *show_path,
|
||||
IsoNode *node, int depth, int flag)
|
||||
{
|
||||
@ -3771,13 +3791,15 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
ret= Xorriso_ls_filev(xorriso, "", 1, &abs_path, (off_t) 0, 1|2|8);
|
||||
} else if(action>=9 && action<=13) { /* actions which have own findjobs */
|
||||
Findjob_set_start_path(subjob, abs_path, 0);
|
||||
ret= Xorriso_findi(xorriso, subjob, NULL, abs_path, &dir_stbuf, depth, 0);
|
||||
} else if(action==14) { /* compare */
|
||||
ret= Xorriso_findi(xorriso, subjob, boss_iter, NULL,
|
||||
abs_path, &dir_stbuf, depth, 0);
|
||||
} else if(action==14 || action==17) { /* compare , update */
|
||||
Findjob_get_start_path(job, &iso_prefix, 0);
|
||||
ret= Xorriso_find_compare(xorriso, abs_path, iso_prefix, target, 0);
|
||||
ret= Xorriso_find_compare(xorriso, (void *) boss_iter, abs_path, iso_prefix, target,
|
||||
(action==17));
|
||||
if(ret>=0)
|
||||
ret= 1;
|
||||
} else if(action==16) { /* not_in_iso */
|
||||
} else if(action==16 || action==18) { /* not_in_iso , add_missing */
|
||||
;
|
||||
} else { /* includes : 15 in_iso */
|
||||
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
|
||||
@ -3789,6 +3811,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
|
||||
|
||||
int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
void *boss_iter,
|
||||
void *dir_node_generic, char *dir_path,
|
||||
struct stat *dir_stbuf, int depth, int flag)
|
||||
{
|
||||
@ -3842,8 +3865,8 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
if(ret<0)
|
||||
goto ex;
|
||||
if(ret>0) {
|
||||
ret= Xorriso_findi_action(xorriso, job, path, dir_path,
|
||||
(IsoNode *) dir_node, depth, 0);
|
||||
ret= Xorriso_findi_action(xorriso, job, (IsoDirIter *) boss_iter,
|
||||
path, dir_path, (IsoNode *) dir_node, depth, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
}
|
||||
@ -3874,7 +3897,8 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, path, abs_path, 1|2|4);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
ret= Xorriso_findi_action(xorriso, job, abs_path, path, node, depth, 0);
|
||||
ret= Xorriso_findi_action(xorriso, job, iter,
|
||||
abs_path, path, node, depth, 0);
|
||||
if(ret<=0) {
|
||||
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
|
||||
goto ex;
|
||||
@ -3882,7 +3906,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
}
|
||||
|
||||
if(S_ISDIR(stbuf.st_mode)) {
|
||||
ret= Xorriso_findi(xorriso, job, (void *) node, path,
|
||||
ret= Xorriso_findi(xorriso, job, (void *) iter, (void *) node, path,
|
||||
&stbuf, depth+1, flag);
|
||||
if(ret<0)
|
||||
goto ex;
|
||||
|
Reference in New Issue
Block a user