/* ** If arg is a file wildcard specification, then figure out all matches and pass ** each match, one by one, to k2_proc_arg. */ void k2pdfopt_proc_wildarg(K2PDFOPT_SETTINGS *k2settings,char *arg,int process, K2PDFOPT_OUTPUT *k2out) { int i; #if (WILLUSDEBUGX & 1) printf("@k2pdfopt_proc_wildarg(%s)\n",arg); #endif /* Init width to -1 */ if (k2settings->preview_page!=0 && k2out->bmp!=NULL) k2out->bmp->width = -1; if (wfile_status(arg)==0) { FILELIST *fl,_fl; fl=&_fl; filelist_init(fl); filelist_fill_from_disk_1(fl,arg,0,0); if (fl->n==0) { #ifdef HAVE_K2GUI if ((!k2gui_active() && process) || (k2gui_active() && !process)) #endif k2printf(TTEXT_WARN "\n** File or folder %s could not be opened. **\n\n" TTEXT_NORMAL,arg); #ifdef HAVE_K2GUI if (process && k2gui_active()) { char buf[512]; sprintf(buf,"File or folder %s cannot be opened.",arg); if (k2settings->preview_page>0) k2gui_alertbox(0,"File not found",buf); else { k2gui_cbox_increment_error_count(); k2gui_cbox_set_pages_completed(0,buf); } } #endif return; } for (i=0;i<fl->n;i++) { char fullname[512]; wfile_fullname(fullname,fl->dir,fl->entry[i].name); k2pdfopt_proc_arg(k2settings,fullname,process,k2out); } } else k2pdfopt_proc_arg(k2settings,arg,process,k2out); }
void k2gui_cbox_error(char *filename,int statuscode) { static char *err[] = {"Uknown error","No bitmaps found","No DjVuLibre library", "File overwrite not allowed","","Uknown error"}; char buf[512]; if (k2gui_cbox==NULL || !k2gui_cbox->converting) return; if (statuscode<1 || statuscode>5) statuscode=1; sprintf(buf,"Conversion of file %s aborted (%s).",filename,err[statuscode-1]); k2printf("\n\n** %s **\n\n\n",buf); k2gui_cbox_increment_error_count(); k2gui_cbox_set_pages_completed(0,buf); }
/* ** If arg is a folder, look for files inside of it for PDFs / DJVU files and process ** one by one, otherwise just process the passed argument. ** ** Processing file is two steps: ** 1. If auto-rotation is requested, determine the proper rotation of the file. ** 2. Process the file with the determined rotation. ** */ static void k2pdfopt_proc_arg(K2PDFOPT_SETTINGS *k2settings,char *arg,int process, K2PDFOPT_OUTPUT *k2out) { char filename[MAXFILENAMELEN]; int i; double rot; int autorot; #if (WILLUSDEBUGX & 1) printf("@k2pdfopt_proc_arg(%s)\n",arg); printf("wfile_status(%s) = %d\n",arg,wfile_status(arg)); #endif strcpy(filename,arg); if (wfile_status(filename)==0) { #ifdef HAVE_K2GUI if ((!k2gui_active() && process) || (k2gui_active() && !process)) #endif k2printf(TTEXT_WARN "\n** File or folder %s could not be opened. **\n\n" TTEXT_NORMAL,filename); #ifdef HAVE_K2GUI if (process && k2gui_active()) { char buf[512]; k2gui_cbox_increment_error_count(); sprintf(buf,"File %s cannot be opened.",filename); if (k2settings->preview_page>0) k2gui_alertbox(0,"File not found",buf); else k2gui_cbox_set_pages_completed(0,buf); } #endif return; } if (k2settings->info) /* Info only? */ autorot = 0; else if (k2settings->preview_page!=0) autorot = (fabs(k2settings->src_rot - SRCROT_AUTOPREV)<.5); else autorot = (fabs(k2settings->src_rot - SRCROT_AUTOPREV)<.5 || fabs(k2settings->src_rot - SRCROT_AUTO)<.5 || fabs(k2settings->src_rot - SRCROT_AUTOEP)<.5); /* If folder, first process all PDF/DJVU/PS files in the folder */ if (wfile_status(filename)==2) { static char *eolist[]={""}; static char *pdflist[]={"*.pdf","*.djvu","*.djv","*.ps","*.eps",""}; static char *bmplist[]={"*.png","*.jpg",""}; FILELIST *fl,_fl; FILELIST *fl2,_fl2; int nbmp; fl=&_fl; filelist_init(fl); filelist_fill_from_disk(fl,filename,pdflist,eolist,0,0); fl2=&_fl2; filelist_init(fl2); filelist_fill_from_disk(fl2,filename,bmplist,eolist,0,0); nbmp=fl2->n; filelist_free(fl2); if (fl->n>0) { for (i=0;i<fl->n;i++) { char fullname[512]; wfile_fullname(fullname,filename,fl->entry[i].name); if (autorot) { if (process) rot=k2pdfopt_proc_one(k2settings,fullname,SRCROT_AUTO,k2out); else rot=0.; } else rot=k2settings->src_rot < -990. ? 0. : k2settings->src_rot; if (process) k2pdfopt_proc_one(k2settings,fullname,rot,k2out); if (!process || k2out->status==0) k2out->filecount++; #ifdef HAVE_K2GUI if (process && k2gui_active()) { if (k2out->status!=0) k2gui_cbox_error(filename,k2out->status); else k2gui_cbox_set_files_completed(k2out->filecount,NULL); } #endif } } filelist_free(fl); if (nbmp==0) return; } if (autorot) { if (process) rot=k2pdfopt_proc_one(k2settings,filename,SRCROT_AUTO,k2out); else rot=0.; } else rot=k2settings->src_rot < -990. ? 0. : k2settings->src_rot; if (process) k2pdfopt_proc_one(k2settings,filename,rot,k2out); if (!process || k2out->status==0) k2out->filecount++; #ifdef HAVE_K2GUI if (process && k2gui_active()) { if (k2out->status!=0) k2gui_cbox_error(filename,k2out->status); else k2gui_cbox_set_files_completed(k2out->filecount,NULL); } #endif }