Producing ERRFILE messages where appropriate

This commit is contained in:
2008-02-22 11:49:57 +00:00
parent 1f01e954d4
commit 5fe8ac9f7f
4 changed files with 76 additions and 18 deletions

View File

@ -3650,6 +3650,7 @@ int Xorriso_resolve_link(struct XorrisO *xorriso,
l= readlink(lpt, buf, SfileadrL-1);
if(l==-1) {
handle_error:;
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text, "Cannot obtain link target of : %s",
Text_shellsafe(link_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
@ -3664,6 +3665,7 @@ handle_abort:;
}
buf[l]= 0;
if(l==0) {
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text, "Empty link target with : %s",
Text_shellsafe(link_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
@ -3702,6 +3704,7 @@ handle_abort:;
link_count++;
if(link_count>link_limit) {
too_many_hops:;
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text, "Too many link hops with : %s",
Text_shellsafe(link_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, show_errno,
@ -4621,6 +4624,7 @@ int Xorriso_expand_disk_pattern(struct XorrisO *xorriso,
strcpy(dir_adr, "/");
ret= Sfile_type(dir_adr, 1|4);
if(ret!=2) {
Xorriso_msgs_submit(xorriso, 0, dir_adr, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"Address set by -cdx is not a directory: %s",
Text_shellsafe(dir_adr, sfe, 0));
@ -5975,7 +5979,7 @@ int Xorriso_cpmv_args(struct XorrisO *xorriso, char *cmd,
int *optc, char ***optv, char eff_dest[SfileadrL],
int flag)
{
int destc= 0, is_dir=0, end_idx, ret;
int destc= 0, is_dir=0, end_idx, ret, i;
char **destv= NULL;
char sfe[5*SfileadrL];
@ -6004,6 +6008,8 @@ int Xorriso_cpmv_args(struct XorrisO *xorriso, char *cmd,
if(ret==2 || ((flag&1) && *optc > 1 && ret==0)) {
is_dir= 1;
} else if(*optc > 1) {
for(i= 0; i<*optc; i++)
Xorriso_msgs_submit(xorriso, 0, (*optv)[i], 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"%s: more than one origin given, destination is a non-directory: %s",
cmd, Text_shellsafe(destv[0], sfe, 0));
@ -7186,12 +7192,14 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag)
if(eff_path[0]) {
ret= Sfile_type(eff_path,1|4|8);
if(ret<0) {
Xorriso_msgs_submit(xorriso, 0, eff_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,"-cdx: file not found : %s",
Text_shellsafe(eff_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
if(ret!=2) {
Xorriso_msgs_submit(xorriso, 0, eff_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"-cdx: not a directory : %s",
Text_shellsafe(eff_path, sfe, 0));
@ -8805,6 +8813,7 @@ int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag)
int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
{
int ret,linecount= 0, insertcount= 0, null= 0, was_failure= 0, fret= 0;
int was_ferror= 0, list_errfile= 0;
FILE *fp= NULL;
char *argpt, sfe[5*SfileadrL],line[SfileadrL];
@ -8821,9 +8830,21 @@ int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
if(Sfile_fgets(line,sizeof(line),fp)==NULL) {
ret= 1;
if(ferror(fp))
ret= 0;
was_ferror= 1;
break;
}
/* <<< disabled for now: list all files which get not processed after
the problem evaluator decided to abort. Actually the whole program
will abort and thus further commands will not report their omitted
files.
*/
if(list_errfile) {
if(line[0])
Xorriso_msgs_submit(xorriso, 0, line, 0, "ERRFILE", 0);
continue;
}
linecount++;
if(line[0]==0)
continue;
@ -8840,18 +8861,25 @@ problem_handler:;
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
if(fret>=0)
continue;
#ifdef NIX
list_errfile= 1; /* <<< disabled : see above */
#else
goto ex;
#endif
}
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
xorriso->pacifier_total, "", 1);
ret= 1;
ex:;
if(ret<=0) {
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
xorriso->pacifier_total, "", 1);
if(ret<=0 || list_errfile) {
sprintf(xorriso->info_text, "Aborted reading of file %s in line number %d",
Text_shellsafe(adr, sfe, 0), linecount);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
(fret==-2 ? "NOTE" : "FAILURE"), 0);
}
ret= !(was_ferror || list_errfile);
sprintf(xorriso->info_text, "Added %d items from file %s\n",
insertcount, Text_shellsafe(adr, sfe, 0));
Xorriso_info(xorriso,0);