Implemented reassure for -blank, -format, -dev, -indev, -devices

This commit is contained in:
Thomas Schmitt 2008-02-05 19:15:43 +00:00
parent eec3eaa5e9
commit c6d5158388
4 changed files with 62 additions and 21 deletions

View File

@ -1010,15 +1010,21 @@ before rolling back pending image changes,
.br
before committing image changes to media,
.br
before changing the input drive,
.br
before blanking or formatting media,
.br
before ending the program.
.br
With setting "tree" the reassuring prompt will appear for an eventual
directory only once and not for each file in its whole subtree.
Setting "off" silently kills any kind of image file object.
To really produce user prompts, option -dialog needs to be set to "on".
.br
Note that the prompt appears only in situations where file removal
is not forbidden by option -overwrite. -reassure only imposes an additional
Setting "off" silently kills any kind of image file object resp. performs
above irrevocable actions.
.br
To really produce user prompts, option -dialog needs to be set to "on".
Note that the prompt does not appear in situations where file removal
is forbidden by option -overwrite. -reassure only imposes an additional
curb for removing existing file objects.
.br
Be aware that file objects get deleted from the ISO image immediately

View File

@ -5962,6 +5962,8 @@ int Xorriso_reassure(struct XorrisO *xorriso, char *cmd, char *which_will,
{
int ret;
if(!xorriso->do_reassure)
return(1);
sprintf(xorriso->info_text, "Really perform %s which will %s ? (y/n)\n",
cmd, which_will);
Xorriso_info(xorriso, 4);
@ -6183,7 +6185,9 @@ int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag)
/* Option -blank and -format */
/* @param flag bit0= format rather than blank */
/* @param flag bit0= format rather than blank
@return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag)
{
char drive_name[SfileadrL], *cmd= "-blank", sfe[5*SfileadrL];
@ -6206,6 +6210,10 @@ int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag)
}
aq_flag= 3;
}
ret= Xorriso_reassure(xorriso, cmd,
"possibly make unreadable data on outdev", 0);
if(ret<=0)
return(2);
if(strcmp(mode, "all")==0 || strcmp(mode, "full")==0)
mode_flag= 0;
@ -6557,7 +6565,7 @@ int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
if(flag&1)
return(1);
strcpy(newdev, xorriso->outdev);
ret= Xorriso_option_dev(xorriso, newdev, 3);
ret= Xorriso_option_dev(xorriso, newdev, 3|4);
return(ret);
}
@ -6576,7 +6584,7 @@ int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which, int flag)
eret= 1;
else
eret= Xorriso_option_eject(xorriso, which, 0);
ret= Xorriso_option_dev(xorriso, "", 3);
ret= Xorriso_option_dev(xorriso, "", 3|4);
if(eret<ret)
return(eret);
return(ret);
@ -6658,7 +6666,11 @@ int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path,
/* Options -dev , -indev, -outdev */
/** @param flag bit0=use as indev , bit1= use as outdev */
/** @param flag bit0=use as indev
bit1= use as outdev
bit2= do not -reassure
@return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
{
int ret;
@ -6691,6 +6703,12 @@ int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
if((flag&1) && !(flag&4)) {
ret= Xorriso_reassure(xorriso, (flag&2) ? "-dev" : "-indev",
"eventually discard the current image", 0);
if(ret<=0)
return(2);
}
if(adr[0]==0) {
if((flag&1) && xorriso->in_drive_handle != NULL) {
@ -6718,6 +6736,8 @@ int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
/* Option -devices */
/* @return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_devices(struct XorrisO *xorriso, int flag)
{
int ret;
@ -6729,6 +6749,10 @@ int Xorriso_option_devices(struct XorrisO *xorriso, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
ret= Xorriso_reassure(xorriso, "-devices",
"eventually discard the current image", 0);
if(ret<=0)
return(2);
xorriso->info_text[0]= 0;
if(xorriso->in_drive_handle!=NULL || xorriso->out_drive_handle!=NULL) {
if(xorriso->in_drive_handle == xorriso->out_drive_handle) {
@ -6812,6 +6836,7 @@ int Xorriso_option_eject(struct XorrisO *xorriso, char *which, int flag)
/* Options -end , and -rollback_end */
/* @param flag bit0= discard pending changes
bit1= do not -reassure
@return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_end(struct XorrisO *xorriso, int flag)
@ -6831,9 +6856,11 @@ int Xorriso_option_end(struct XorrisO *xorriso, int flag)
} else {
which_will= "end the program";
}
ret= Xorriso_reassure(xorriso, cmd, which_will, 0);
if(ret<=0)
return(2);
if(!(flag&2)) {
ret= Xorriso_reassure(xorriso, cmd, which_will, 0);
if(ret<=0)
return(2);
}
if(xorriso->volset_change_pending) {
if(flag&1) {
@ -8194,7 +8221,7 @@ int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
ret= Xorriso_give_up_drive(xorriso, 1|8);
if(ret<=0)
return(ret);
ret= Xorriso_option_dev(xorriso, indev, 1);
ret= Xorriso_option_dev(xorriso, indev, 1|4);
/*
1|((xorriso->out_drive_handle==NULL)<<1));
*/
@ -8435,7 +8462,7 @@ return:
bit0= recursion
*/
{
int ret, was_dashed;
int ret, was_dashed, end_ret;
int num1, num2;
double d1, d2;
char *cmd, *arg1, *arg2, *arg4;
@ -8593,11 +8620,12 @@ next_command:;
ret= Xorriso_option_eject(xorriso, arg1, 0);
} else if(strcmp(cmd,"end")==0) {
Xorriso_option_end(xorriso, 0);
end_ret= Xorriso_option_end(xorriso, 0);
ret= Xorriso_eval_problem_status(xorriso, ret, 0);
if(ret<0)
return(ret);
{ret= 3; goto ex;}
if(end_ret!=2)
{ret= 3; goto ex;}
} else if(strcmp(cmd,"iso_rr_pattern")==0) {
(*idx)++;
@ -8757,11 +8785,12 @@ next_command:;
ret= Xorriso_option_rollback(xorriso, 0);
} else if(strcmp(cmd,"rollback_end")==0) {
Xorriso_option_end(xorriso, 1);
end_ret= Xorriso_option_end(xorriso, 1);
ret= Xorriso_eval_problem_status(xorriso, ret, 0);
if(ret<0)
return(ret);
{ret= 3; goto ex;}
if(end_ret!=2)
{ret= 3; goto ex;}
} else if(strcmp(cmd,"speed")==0) {
(*idx)++;
@ -9165,7 +9194,7 @@ int Xorriso_main(int argc, char **argv)
end_sucessfully:;
Xorriso_process_msg_queues(xorriso, 0);
if(xorriso->volset_change_pending)
Xorriso_option_end(xorriso, 0);
Xorriso_option_end(xorriso, 2);
Xorriso_process_msg_queues(xorriso, 0);
Xorriso_destroy(&xorriso,1);
exit(0);

View File

@ -169,7 +169,9 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso,
int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag);
/* Option -blank and -format */
/* @param flag bit0= format rather than blank */
/* @param flag bit0= format rather than blank
@return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag);
/* Option -cd alias -cdi */
@ -221,10 +223,14 @@ int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path,
off_t startbyte, off_t bytecount, char *iso_rr_path, int flag);
/* Options -dev , -indev, -outdev */
/** @param flag bit0=use as indev , bit1= use as outdev */
/* @param flag bit0=use as indev , bit1= use as outdev
@return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_dev(struct XorrisO *xorriso, char *adr, int flag);
/* Option -devices */
/* @return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_devices(struct XorrisO *xorriso, int flag);
/* Option -dialog "on"|"off" */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.02.05.175733"
#define Xorriso_timestamP "2008.02.05.191456"