New -find actions update_merge, rm_merge, clear_merge. -cp_clone now merges.

This commit is contained in:
2011-02-12 17:14:23 +00:00
parent 4642148e6f
commit 26a6a24093
18 changed files with 435 additions and 116 deletions

View File

@ -284,6 +284,7 @@ ex:;
bit1= compare ctime
bit2= check only existence of both file objects
count one or both missing as "difference"
bit26= do not issue message about missing disk file
bit27= for Xorriso_path_is_excluded(): bit0
bit28= examine eventual disk_path link target rather than link
bit29= do not issue pacifier messages
@ -320,7 +321,7 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
sprintf(respt , "? %s (DISK) : exluded by %s\n",
Text_shellsafe(disk_adr, sfe, 0),
(ret==1 ? "-not_paths" : "-not_leaf"));
if(!(flag&(1<<31)))
if(! (flag & ((1 << 31) | (1 << 26))))
Xorriso_result(xorriso,0);
missing= 1;
(*result)|= 1;
@ -334,7 +335,7 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
if(ret==-1) {
sprintf(respt , "? %s (DISK) : cannot lstat() : %s\n",
Text_shellsafe(disk_adr, sfe, 0), strerror(errno));
if(!(flag&(1<<31)))
if(! (flag & ((1 << 31) | (1 << 26))))
Xorriso_result(xorriso,0);
missing= 1;
(*result)|= 1;
@ -681,10 +682,11 @@ int Xorriso_pfx_disk_path(struct XorrisO *xorriso, char *iso_path,
Set to NULL if calling this function from outside ISO world
@param flag bit0= update rather than compare
bit1= find[ix] is in recursion
bit2= update_merge : do not delete but mark visited and found
@return <=0 error, 1= ok , 2= iso_path was deleted
3=ok, do not dive into directory (e.g. because it is a split file)
*/
int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter,
int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, void *node,
char *iso_path, char *iso_prefix, char *disk_prefix,
int flag)
{
@ -709,22 +711,24 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter,
follow_links= (xorriso->do_follow_links ||
(xorriso->do_follow_param && !(flag&2))) <<28;
ret= Xorriso_compare_2_files(xorriso, disk_path, iso_path, "", &result,
2 | follow_links | ((!(flag&2))<<27) | ((flag&1)<<31));
2 | follow_links | ((!!(flag & 4)) << 26)
| ((!(flag&2))<<27) | ((flag&1)<<31));
/* was once: | ((!(flag&1))<<29) */
if(ret<xorriso->find_compare_result)
xorriso->find_compare_result= ret;
if(flag&1) {
if(ret<=0) {
if(ret<0)
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
return(ret);
uret= Xorriso_update_interpreter(xorriso, boss_iter, result,
disk_path, iso_path, (flag&2)<<1);
if(uret<=0)
ret= 0;
if(uret==2)
deleted= 1;
}
if(ret<0)
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
return(ret);
if(ret > 0)
result= 0;
uret= Xorriso_update_interpreter(xorriso, boss_iter, node, result,
disk_path, iso_path,
((flag & 2) << 1) | ((flag & 4) >> 1));
if(uret<=0)
ret= 0;
if(uret==2)
deleted= 1;
}
if(ret<0)
return(ret);
@ -742,11 +746,15 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter,
Do not call Xorriso_hardlink_update()
Overwrite exactly if normal mode would not,
else do nothing
bit1= do not delete files which are not found under
disk_path, but rather mark visited files and mark
files which were found.
bit2= -follow: this is not a command parameter
@return <=0 error, 1= ok , 2= iso_rr_path node object has been deleted ,
3= no action taken
*/
int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
int Xorriso_update_interpreter(struct XorrisO *xorriso,
void *boss_iter, void *node,
int compare_result, char *disk_path,
char *iso_rr_path, int flag)
{
@ -767,6 +775,15 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
ret= 3; goto ex;
}
if((flag & 2) && !(compare_result & 2)) {
ret= Xorriso_mark_update_merge(xorriso, iso_rr_path, node,
!(compare_result & 1));
if(ret <= 0)
goto ex;
}
if(compare_result == 0)
{ret= 1; goto ex;}
if(compare_result&((1<<11)|(1<<13))) {
if(flag & 1)
{ret= 3; goto ex;}
@ -806,15 +823,24 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
deleted= 1;
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path,
(off_t) 0, (off_t) 0, 2|(flag&4));
if(ret <= 0)
goto ex;
if(flag & 2) {
ret= Xorriso_mark_update_merge(xorriso, iso_rr_path, NULL, 1);
if(ret <= 0)
goto ex;
}
}
sprintf(xorriso->info_text, "Deleted and re-added ");
} else if(compare_result&(1)) {
delete:;
/* disk_adr not existing */
ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1);
deleted= 1;
sprintf(xorriso->info_text, "Deleted ");
if(!(flag & 2)) {
ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1);
deleted= 1;
sprintf(xorriso->info_text, "Deleted ");
}
} else if(compare_result&(2|128|(1<<12)|(1<<14)|(1<<15))) {
/* iso_adr not existing, size, cannot open iso file, early eof of iso file
@ -895,6 +921,11 @@ overwrite:;
if(ret < 0)
goto ex;
}
if(flag & 2) {
ret= Xorriso_mark_update_merge(xorriso, iso_rr_path, NULL, 1);
if(ret <= 0)
goto ex;
}
if(flag & 1)
sprintf(xorriso->info_text, "Widened hard link ");
else