Implemented option -rmdir

This commit is contained in:
Thomas Schmitt 2007-11-07 15:01:20 +00:00
parent 3d27db24f1
commit f46827aa62
5 changed files with 55 additions and 53 deletions

View File

@ -331,7 +331,7 @@ Create empty directories if they do not exist yet.
Existence as directory generates a WARNING event, existence as
other file cause a SORRY event.
.TP
> \fB\-rmdir\fR iso_rr_path [...]
\fB\-rmdir\fR iso_rr_path [...]
Delete empty directories.
.TP
\fB\-\-\fR

View File

@ -1994,40 +1994,40 @@ int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag)
xorriso->result_page_length= -xorriso->result_page_length;
cpt= line;
if(*cpt=='@') {
if(strcmp(cpt,"@@@")==0) {
request_to_abort:;
if(flag&1) {
strcpy(previous_line,cpt);
sprintf(xorriso->info_text,
"....... [%s = %s registered. Really %s ? (y/n) ] .......\n",
cpt,abort_req_text,abort_really_text);
Xorriso_info(xorriso,0);
ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1);
if(ret<=0)
return(ret);
cpt= line;
if(strcmp(cpt,previous_line)==0 ||
((*cpt=='Y' || *cpt=='y' || *cpt=='j' || *cpt=='J' || *cpt=='1') &&
*(cpt+1)==0)) {
xorriso->request_to_abort= 1;
sprintf(xorriso->info_text,
"------- ( %s confirmed )\n",abort_req_text);
Xorriso_info(xorriso,0);
return(2);
}
sprintf(xorriso->info_text,
"....... ( %s revoked )\n",abort_req_text);
Xorriso_info(xorriso,0);
return(3);
}
xorriso->request_to_abort= 1;
if(strcmp(cpt,"@@@")==0 ||
strcmp(cpt,"x")==0 || strcmp(cpt,"X")==0 ||
strcmp(cpt,"q")==0 || strcmp(cpt,"Q")==0) {
if(flag&1) {
strcpy(previous_line,cpt);
sprintf(xorriso->info_text,
"----------- [%s = request to abort registered. Operation ends ] ------------\n",
cpt);
"....... [%s = %s registered. Really %s ? (y/n) ] .......\n",
cpt,abort_req_text,abort_really_text);
Xorriso_info(xorriso,0);
return(2);
} else if(strcmp(cpt,"@@")==0) {
ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1);
if(ret<=0)
return(ret);
cpt= line;
if(strcmp(cpt,previous_line)==0 ||
((*cpt=='Y' || *cpt=='y' || *cpt=='j' || *cpt=='J' || *cpt=='1') &&
*(cpt+1)==0)) {
xorriso->request_to_abort= 1;
sprintf(xorriso->info_text,
"------- ( %s confirmed )\n",abort_req_text);
Xorriso_info(xorriso,0);
return(2);
}
sprintf(xorriso->info_text, "....... ( %s revoked )\n",abort_req_text);
Xorriso_info(xorriso,0);
return(3);
}
xorriso->request_to_abort= 1;
sprintf(xorriso->info_text,
"----------- [%s = request to abort registered. Operation ends ] ------------\n",
cpt);
Xorriso_info(xorriso,0);
return(2);
} else if(*cpt=='@') {
if(strcmp(cpt,"@@")==0) {
goto klammer_affe;
} else if(strcmp(cpt,"@")==0) {
@ -2061,9 +2061,6 @@ klammer_affe:;
} else if(strcmp(cpt,"r")==0 || strcmp(cpt,"R")==0 ||
strcmp(cpt,"y")==0 || strcmp(cpt,"Y")==0) {
return(6);
} else if(strcmp(cpt,"x")==0 || strcmp(cpt,"X")==0 ||
strcmp(cpt,"q")==0 || strcmp(cpt,"Q")==0) {
goto request_to_abort;
} else {
/* >>> unknown input */
sprintf(xorriso->info_text,
@ -3870,15 +3867,15 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" access time, modification time, both times.",
" -mkdir iso_rr_path [...]",
" Create empty directories if they do not exist yet",
"> -rmdir iso_rr_path [...]",
" -rmdir iso_rr_path [...]",
" Delete empty directories.",
" -- Mark end of particular action argument list.",
"",
"> -f Follow symbolic links within disk_path.",
"",
"> -overwrite \"on\"|\"off\"",
" -overwrite \"on\"|\"off\"",
" Allow or disallow to overwrite existing files in ISO image.",
"> -reassure \"on\"|\"off\"",
" -reassure \"on\"|\"off\"",
" If \"on\" then ask the user for \"y\" or \"n\" with any",
" file before deleting or overwriting it in the ISO image.",
"",
@ -4605,8 +4602,8 @@ int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity,
}
/* Options -rm alias -rmi , and -rm_r aias -rm_ri */
/* @param flag bit0=recursive */
/* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */
/* @param flag bit0=recursive , bit2= remove empty directory: rmdir */
int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag)
{
@ -4628,12 +4625,12 @@ int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
return(ret);
strcpy(path, eff_path);
ret= Xorriso_rmi(xorriso, NULL, path, flag&1);
ret= Xorriso_rmi(xorriso, NULL, path, flag&(1|2));
if(ret<=0)
goto ex;
if(ret<3) {
sprintf(xorriso->info_text, "Removed from ISO image: %s '%s'\n",
(ret>1 ? "subtree" : "file"), path);
((flag&2) ? "directory" : (ret>1 ? "subtree" : "file")), path);
Xorriso_info(xorriso, 0);
}
}
@ -5158,7 +5155,7 @@ next_command:;
ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 1);
} else if(strcmp(cmd,"-rmdir")==0 || strcmp(cmd,"-rmdiri")==0) {
ret= Xorriso_option_rmdiri(xorriso, argc, argv, idx, 0);
ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 2);
} else if(strcmp(cmd,"-rollback")==0) {
ret= Xorriso_option_rollback(xorriso, 0);

View File

@ -286,15 +286,11 @@ int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity,
/* Option -reassure "on"|"tree"|"off" */
int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag);
/* Options -rm alias -rmi , and -rm_r aias -rm_ri */
/* @param flag bit0=recursive */
/* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */
/* @param flag bit0=recursive , bit2= remove empty directory: rmdir */
int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag);
/* Option -rmdir alias -rmdiri */
int Xorriso_option_rmdiri(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag);
/* Option -rollback */
int Xorriso_option_rollback(struct XorrisO *xorriso, int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.11.07.123744"
#define Xorriso_timestamP "2007.11.07.150157"

View File

@ -1422,7 +1422,14 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter,
if(LIBISO_ISDIR(victim_node))
is_dir= 1;
if(is_dir) {
if(!is_dir) {
if(flag&2) { /* rmdir */
sprintf(xorriso->info_text, "%s in loaded ISO image is not a directory",
Text_shellsafe(path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
}
} else {
if(flag&1) { /* rm -r */
if(xorriso->do_reassure==1 && !xorriso->request_not_to_ask) {
/* Iterate over subordinates and delete them */
@ -1469,7 +1476,9 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter,
iter= iso_tree_node_children((struct iso_tree_node_dir *) victim_node);
Xorriso_process_msg_queues(xorriso,0);
if(iso_tree_iter_next(iter)!=NULL) {
sprintf(xorriso->info_text, "Directory not empty on attempt to delete");
sprintf(xorriso->info_text,
"Directory not empty on attempt to delete: %s",
Text_shellsafe(path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
}