Implemented reassure for -rollback, -rollback_end, -end, -commit, -commit_eject
This commit is contained in:
@ -5954,6 +5954,35 @@ ex:;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/** @return -1= abort , 0= no , 1= yes
|
||||
*/
|
||||
int Xorriso_reassure(struct XorrisO *xorriso, char *cmd, char *which_will,
|
||||
int flag)
|
||||
{
|
||||
int ret;
|
||||
|
||||
sprintf(xorriso->info_text, "Really perform %s which will %s ? (y/n)\n",
|
||||
cmd, which_will);
|
||||
Xorriso_info(xorriso, 4);
|
||||
do {
|
||||
ret= Xorriso_request_confirmation(xorriso, 2|4|16);
|
||||
} while(ret==3);
|
||||
if(ret==6 || ret==4) {
|
||||
sprintf(xorriso->info_text, "%s confirmed", cmd);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
return(1);
|
||||
}
|
||||
if(ret==2) {
|
||||
sprintf(xorriso->info_text, "%s aborted", cmd);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
return(-1);
|
||||
}
|
||||
sprintf(xorriso->info_text, "%s revoked", cmd);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------- Options API ------------------------ */
|
||||
|
||||
@ -6502,6 +6531,8 @@ int Xorriso_option_close(struct XorrisO *xorriso, char *mode, int flag)
|
||||
/* Option -commit */
|
||||
/* @param flag bit0= leave indrive and outdrive aquired as they were,
|
||||
i.e. do not aquire outdrive as new in-out-drive
|
||||
bit1= do not perform eventual -reassure
|
||||
@return <=0 error , 1 success, 2 revoked by -reassure , 3 no change pending
|
||||
*/
|
||||
int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
@ -6509,9 +6540,15 @@ int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
|
||||
char newdev[SfileadrL];
|
||||
|
||||
if(!xorriso->volset_change_pending) {
|
||||
sprintf(xorriso->info_text,"-commit: No image modifications pending");
|
||||
sprintf(xorriso->info_text, "-commit: No image modifications pending");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||
return(2);
|
||||
return(3);
|
||||
}
|
||||
if(!(flag&2)) {
|
||||
ret= Xorriso_reassure(xorriso, "-commit",
|
||||
"write the pending image changes to media", 0);
|
||||
if(ret<=0)
|
||||
return(2);
|
||||
}
|
||||
ret= Xorriso_write_session(xorriso, 0);
|
||||
if(ret<=0)
|
||||
@ -6525,13 +6562,15 @@ int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
|
||||
/* Option -commit_eject */
|
||||
/* Option -commit_eject */
|
||||
/* @return <=0 error , 1 success, 2 revoked by -reassure
|
||||
*/
|
||||
int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which, int flag)
|
||||
{
|
||||
int ret, eret;
|
||||
|
||||
ret= Xorriso_option_commit(xorriso, 1);
|
||||
if(ret<=0)
|
||||
if(ret<=0 || ret==2)
|
||||
return(ret);
|
||||
if(strcmp(which, "none")==0 || strcmp(which, "")==0)
|
||||
eret= 1;
|
||||
@ -6772,10 +6811,29 @@ int Xorriso_option_eject(struct XorrisO *xorriso, char *which, int flag)
|
||||
|
||||
|
||||
/* Options -end , and -rollback_end */
|
||||
/* @param flag bit0= discard pending changes */
|
||||
/* @param flag bit0= discard pending changes
|
||||
@return <=0 error , 1 success, 2 revoked by -reassure
|
||||
*/
|
||||
int Xorriso_option_end(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
int ret;
|
||||
char *cmd, *which_will;
|
||||
|
||||
if(flag&1)
|
||||
cmd= "-rollback_end";
|
||||
else
|
||||
cmd= "-end";
|
||||
if(xorriso->volset_change_pending) {
|
||||
if(flag&1)
|
||||
which_will= "end the program discarding image changes";
|
||||
else
|
||||
which_will= "commit image changes and then end the program";
|
||||
} else {
|
||||
which_will= "end the program";
|
||||
}
|
||||
ret= Xorriso_reassure(xorriso, cmd, which_will, 0);
|
||||
if(ret<=0)
|
||||
return(2);
|
||||
|
||||
if(xorriso->volset_change_pending) {
|
||||
if(flag&1) {
|
||||
@ -8116,10 +8174,20 @@ ex:;
|
||||
|
||||
|
||||
/* Option -rollback */
|
||||
/* @return <=0 error , 1 success, 2 revoked by -reassure
|
||||
*/
|
||||
int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
int ret;
|
||||
char indev[SfileadrL];
|
||||
char indev[SfileadrL], *which_will;
|
||||
|
||||
if(xorriso->volset_change_pending)
|
||||
which_will= "revoke the pending image changes";
|
||||
else
|
||||
which_will= "reload the image";
|
||||
ret= Xorriso_reassure(xorriso, "-rollback", which_will, 0);
|
||||
if(ret<=0)
|
||||
return(2);
|
||||
|
||||
if(Sfile_str(indev, xorriso->indev, 0)<=0)
|
||||
return(-1);
|
||||
|
Reference in New Issue
Block a user