|
|
1.1 root 1: #include <ctype.h>
2:
3: #include "dirwrap.h"
4: #include "uifc.h"
5: #include "ciolib.h"
6: #include "mouse.h"
7: #include "keys.h"
8:
9: #include "filepick.h"
10:
11: enum {
12: DIR_LIST
13: ,FILE_LIST
14: ,MASK_FIELD
15: ,CURRENT_PATH
16: ,FIELD_LIST_TERM
17: };
18:
19: void drawfpwindow(uifcapi_t *api)
20: {
21: char lbuf[1024];
22: int i;
23: int j;
24: int listheight=0;
25: int height;
26: int width;
27: char shade[1024];
28:
29: width=SCRN_RIGHT-SCRN_LEFT+1;
30:
31: height=api->scrn_len-3;
32: /* Make sure it's odd */
33: if(!(width%2))
34: width--;
35:
36: listheight=height-7;
37:
38: i=0;
39: lbuf[i++]='\xc9';
40: lbuf[i++]=api->hclr|(api->bclr<<4);
41: for(j=1;j<width-1;j++) {
42: lbuf[i++]='\xcd';
43: lbuf[i++]=api->hclr|(api->bclr<<4);
44: }
45: if(api->mode&UIFC_MOUSE && width>6) {
46: lbuf[2]='[';
47: lbuf[3]=api->hclr|(api->bclr<<4);
1.1.1.2 ! root 48: lbuf[4]='\xfe';
1.1 root 49: lbuf[5]=api->lclr|(api->bclr<<4);
50: lbuf[6]=']';
51: lbuf[7]=api->hclr|(api->bclr<<4);
52: lbuf[8]='[';
53: lbuf[9]=api->hclr|(api->bclr<<4);
54: lbuf[10]='?';
55: lbuf[11]=api->lclr|(api->bclr<<4);
56: lbuf[12]=']';
57: lbuf[13]=api->hclr|(api->bclr<<4);
58: api->buttony=SCRN_TOP;
59: api->exitstart=SCRN_LEFT+1;
60: api->exitend=SCRN_LEFT+3;
61: api->helpstart=SCRN_LEFT+4;
62: api->helpend=SCRN_LEFT+6;
63: }
64: lbuf[i++]='\xbb';
65: lbuf[i]=api->hclr|(api->bclr<<4);
66: puttext(SCRN_LEFT,SCRN_TOP,SCRN_LEFT+width-1,SCRN_TOP,lbuf);
67: lbuf[5]=api->hclr|(api->bclr<<4);
68: lbuf[11]=api->hclr|(api->bclr<<4);
69: for(j=2;j<14;j+=2)
70: lbuf[j]='\xcd';
71: lbuf[0]='\xc8';
72: lbuf[(width-1)*2]='\xbc';
73: puttext(SCRN_LEFT,SCRN_TOP+height-1
74: ,SCRN_LEFT+width-1,SCRN_TOP+height-1,lbuf);
75: lbuf[0]='\xcc';
76: lbuf[(width-1)*2]='\xb9';
77: lbuf[width-1]='\xcb';
78: puttext(SCRN_LEFT,SCRN_TOP+2,SCRN_LEFT+width-1,SCRN_TOP+2,lbuf);
79: lbuf[width-1]='\xca';
80: puttext(SCRN_LEFT,SCRN_TOP+3+listheight
81: ,SCRN_LEFT+width-1,SCRN_TOP+3+listheight,lbuf);
82: lbuf[0]='\xba';
83: lbuf[(width-1)*2]='\xba';
84: for(j=2;j<(width-1)*2;j+=2)
85: lbuf[j]=' ';
86: puttext(SCRN_LEFT,SCRN_TOP+1,
87: SCRN_LEFT+width-1,SCRN_TOP+1,lbuf);
88: puttext(SCRN_LEFT,SCRN_TOP+height-2,
89: SCRN_LEFT+width-1,SCRN_TOP+height-2,lbuf);
90: puttext(SCRN_LEFT,SCRN_TOP+height-3,
91: SCRN_LEFT+width-1,SCRN_TOP+height-3,lbuf);
92: lbuf[width-1]='\xba';
93: for(j=0;j<listheight;j++)
94: puttext(SCRN_LEFT,SCRN_TOP+3+j
95: ,SCRN_LEFT+width-1,SCRN_TOP+3+j,lbuf);
96:
97:
98: /* Shadow */
99: if(api->bclr==BLUE) {
100: gettext(SCRN_LEFT+width,SCRN_TOP+1,SCRN_LEFT+width+1
101: ,SCRN_TOP+(height-1),shade);
102: for(j=1;j<1024;j+=2)
103: shade[j]=DARKGRAY;
104: puttext(SCRN_LEFT+width,SCRN_TOP+1,SCRN_LEFT+width+1
105: ,SCRN_TOP+(height-1),shade);
106: gettext(SCRN_LEFT+2,SCRN_TOP+height,SCRN_LEFT+width+1
107: ,SCRN_TOP+height,shade);
108: for(j=1;j<width*2;j+=2)
109: shade[j]=DARKGRAY;
110: puttext(SCRN_LEFT+2,SCRN_TOP+height,SCRN_LEFT+width+1
111: ,SCRN_TOP+height,shade);
112: }
113: }
114:
115: void free_opt_list(char ***opts)
116: {
117: char **p;
118:
119: if(*opts==NULL)
120: return;
121: for(p=*opts; *p && (*p)[0]; p++) {
122: if(*p)
123: FREE_AND_NULL((*p));
124: }
125: FREE_AND_NULL(*opts);
126: }
127:
128: char *insensitive_mask(char *mask)
129: {
130: #ifdef __unix__
131: char *in;
132: char *out;
133: static char nmask[MAX_PATH*4+1];
134:
135: out=nmask;
136: for(in=mask; *in; in++) {
137: if(isalpha(*in)) {
138: *(out++)='[';
139: *(out++)=tolower(*in);
140: *(out++)=toupper(*in);
141: *(out++)=']';
142: }
143: else
144: *(out++)=*in;
145: }
146: *out=0;
147: return(nmask);
148: #else
149: return(mask);
150: #endif
151: }
152:
153: char *getdirname(char *path)
154: {
155: char *p1;
156: char *p2;
157:
158: p1=strrchr(path,'/');
159: #ifdef _WIN32
160: p2=strrchr(path,'\\');
161: if(p2 > p1)
162: p1=p2;
163: #endif
164: p2 = path;
165: if(p1 > path) {
166: for(p2=p1-1; p2>=path && !IS_PATH_DELIM(*p2); p2--);
167: if(IS_PATH_DELIM(*p2) && *(p2+1))
168: p2++;
169: }
170: return(p2);
171: }
172:
173: char **get_file_opt_list(char **fns, int files, int dirsonly, int root)
174: {
175: char **opts;
176: int i;
177: int j=0;
178:
179: opts=(char **)malloc((files+2)*sizeof(char *));
180: if(opts==NULL)
181: return(NULL);
182: memset(opts, 0, (files+2)*sizeof(char *));
183: if(dirsonly) {
184: if(!root)
185: opts[j++]=strdup("..");
186: }
187: for(i=0;i<files;i++) {
188: if(isdir(fns[i])) {
189: if(dirsonly)
190: opts[j++]=strdup(getdirname(fns[i]));
191: }
192: else {
193: if(!dirsonly)
194: opts[j++]=strdup(getfname(fns[i]));
195: }
196: }
197: opts[j]="";
198: return(opts);
199: }
200:
201: void display_current_path(uifcapi_t *api, char *path)
202: {
203: char dpath[MAX_PATH+2];
1.1.1.2 ! root 204: size_t width;
1.1 root 205: int height;
206: char *p;
207:
208: height=api->scrn_len-3;
209: width=SCRN_RIGHT-SCRN_LEFT-3;
210: SAFECOPY(dpath, path);
211: while(strlen(dpath) > width) {
212: /* Just remove paths from the start. */
213: dpath[0]='.';
214: dpath[1]='.';
215: dpath[2]='.';
216: memmove(dpath+3, dpath+(strlen(dpath)-width+4), width-1);
217: }
218: /* For Win32, convert all "confusing" / to \\ */
219: #ifdef _WIN32
220: for(p=dpath; *p; p++) {
221: if(*p=='/')
222: *p='\\';
223: }
224: #endif
225:
226: api->printf(SCRN_LEFT+2, SCRN_TOP+height-2, api->lclr|(api->bclr<<4), "%-*s", width, dpath);
227: }
228:
229: int mousetofield(int currfield, int opts, int height, int width, int listheight, int listwidth, int *dcur, int *dbar, int *fcur, int *fbar)
230: {
231: int newfield;
232: int bardif;
233: struct mouse_event mevnt;
234:
235: newfield=currfield;
236: if(getmouse(&mevnt)==0) {
237: if(mevnt.endx >= SCRN_LEFT + 1
238: && mevnt.endx <= SCRN_LEFT + listwidth
239: && mevnt.endy >= SCRN_TOP + 3
240: && mevnt.endy <= SCRN_TOP + 2 + listheight) {
241: newfield = DIR_LIST;
242: if(mevnt.endx == SCRN_LEFT + 1)
243: ungetmouse(&mevnt);
244: else {
245: bardif = (mevnt.starty - SCRN_TOP - 3) - *dbar;
246: *dbar += bardif;
247: *dcur += bardif;
248: }
249: }
250: if(mevnt.endx >= SCRN_LEFT + 1 + listwidth + 1
251: && mevnt.endx <= SCRN_LEFT + 1 + listwidth * 2
252: && mevnt.endy >= SCRN_TOP + 3
253: && mevnt.endy <= SCRN_TOP + 2 + listheight) {
254: newfield = FILE_LIST;
255: if(mevnt.endx == SCRN_LEFT + 1 + listwidth + 1)
256: ungetmouse(&mevnt);
257: else {
258: bardif = (mevnt.starty - SCRN_TOP - 3) - *fbar;
259: *fbar += bardif;
260: *fcur += bardif;
261: }
262: }
263: if(!(opts & UIFC_FP_MSKNOCHG)
264: && (mevnt.endx >= SCRN_LEFT + 1
265: && mevnt.endx <= SCRN_LEFT + width - 2
266: && mevnt.endy == SCRN_TOP + height - 3)) {
267: newfield = MASK_FIELD;
268: ungetmouse(&mevnt);
269: }
270: if(opts & UIFC_FP_ALLOWENTRY
271: && mevnt.endx >= SCRN_LEFT + 1
272: && mevnt.endx <= SCRN_LEFT + width - 2
273: && mevnt.endy == SCRN_TOP + height - 2) {
274: newfield = CURRENT_PATH;
275: ungetmouse(&mevnt);
276: }
277: }
278: return(newfield);
279: }
280:
281: int filepick(uifcapi_t *api, char *title, struct file_pick *fp, char *dir, char *msk, int opts)
282: {
283: char cfile[MAX_PATH*5+1]; /* Current full path to file */
284: char cpath[MAX_PATH+1]; /* Current path */
285: char drive[3];
286: char tdir[MAX_PATH+1];
287: char fname[MAX_PATH+1];
288: char ext[MAX_PATH+1];
289: char cmsk[MAX_PATH*4+1]; /* Current file mask */
290: char cglob[MAX_PATH*4+1]; /* File glob patter */
291: char dglob[MAX_PATH*4+1]; /* Directory glob pattern */
292: char *p;
293: glob_t fgl; /* Files */
294: glob_t dgl; /* Directories */
295: int dircur=0;
296: int dirbar=0;
297: int filecur=0;
298: int filebar=0;
299: int listwidth;
300: char **dir_list=NULL;
301: char **file_list=NULL;
302: int currfield=DIR_LIST;
303: int lastfield=DIR_LIST;
304: int i;
305: int root=0; /* Is this the root of the file system? */
306: /* On *nix, this just means no .. on Win32,
307: * Something should be done about drive letters. */
308: int reread=FALSE;
309: int lbclr;
310: char *lastpath=NULL;
311: char *tmplastpath=NULL;
312: char *tmppath=NULL;
313: int width;
314: int height;
315: char *YesNo[]={"Yes", "No", ""};
316: int finished=FALSE;
317: int retval=0;
318: int fieldmove;
1.1.1.2 ! root 319: int oldhu=hold_update;
! 320: int oldx=wherex();
! 321: int oldy=wherey();
1.1 root 322:
323: height=api->scrn_len-3;
324: width=SCRN_RIGHT-SCRN_LEFT-3;
325:
326: lbclr=api->lbclr;
327:
328: /* No struct passed */
329: if(fp==NULL)
330: return(-1);
331:
332: /* Illegal options */
333: if((opts & UIFC_FP_MULTI)==UIFC_FP_MULTI && (opts & (UIFC_FP_ALLOWENTRY|UIFC_FP_OVERPROMPT|UIFC_FP_CREATPROMPT)))
334: return(-1);
335:
336: fp->files=0;
337: fp->selected=NULL;
338:
339: /* No initial path specified */
340: if(dir==NULL || !dir[0])
341: SAFECOPY(cpath,".");
342:
343: FULLPATH(cpath,((dir==NULL||dir[0]==0)?".":dir),sizeof(cpath));
344: backslash(cpath);
345:
346: if(msk==NULL || msk[0]==0) {
347: SAFECOPY(cmsk,"*");
348: }
349: else {
350: SAFECOPY(cmsk,msk);
351: }
352: listwidth=SCRN_RIGHT-SCRN_LEFT+1;
353: listwidth-=listwidth%2;
354: listwidth-=3;
355: listwidth/=2;
356: /* Draw the file picker itself... */
357: hold_update = TRUE;
358: drawfpwindow(api);
359: /* Display the title centered */
360: i=strlen(title);
361: if(i>width-4)
362: i=width-4;
363: api->printf(SCRN_LEFT+2, SCRN_TOP+1, api->hclr|(api->bclr<<4), "%*s%-*s", (width-i)/2-2, "", i, title);
364: api->printf(SCRN_LEFT+2, SCRN_TOP+height-3, api->hclr|(api->bclr<<4), "Mask: ");
365: while(!finished) {
366: hold_update = TRUE;
367: api->printf(SCRN_LEFT+8, SCRN_TOP+height-3, api->lclr|(api->bclr<<4), "%-*s", width-7, cmsk);
368: tmppath=strdup(cpath);
369: if(tmppath != NULL)
370: FULLPATH(cpath,tmppath,sizeof(cpath));
371: FREE_AND_NULL(tmppath);
372:
373: #ifdef __unix__
374: if(cpath[0]==0) {
375: cpath[0]='/';
376: cpath[1]=0;
377: }
378: #endif
379: backslash(cpath);
380: sprintf(cglob,"%s%s",cpath,(opts&UIFC_FP_MSKCASE)?cmsk:insensitive_mask(cmsk));
381: sprintf(dglob,"%s*",cpath);
382: switch(currfield) {
383: case DIR_LIST:
384: if(lastfield==DIR_LIST)
385: sprintf(cfile,"%s%s",cpath,cmsk);
386: break;
387: }
388:
389: #ifdef __unix__
390: if(cpath[0]==0) {
391: cpath[0]='/';
392: cpath[1]=0;
393: }
394: if(cpath[1]==0)
395: root=TRUE;
396: else
397: root=FALSE;
398: #else
399: /* #error Need to do something about root paths (in get_file_opt_list() too!) */
400: #endif
401: if(glob(dglob, GLOB_MARK, NULL, &dgl)!=0 && !isdir(cpath)) {
402: if(lastpath==NULL) {
403: fp->files=0;
404: retval=-1;
405: goto cleanup;
406: }
407: hold_update=FALSE;
408: api->msg("Cannot read directory!");
409: SAFECOPY(cpath, lastpath);
410: FREE_AND_NULL(lastpath);
411: currfield=lastfield;
412: continue;
413: }
414: if(glob(cglob, 0, NULL, &fgl)!=0)
415: fgl.gl_pathc=0;
416: api->list_height=api->scrn_len-3-7;
417: dir_list=get_file_opt_list(dgl.gl_pathv, dgl.gl_pathc, TRUE, root);
418: file_list=get_file_opt_list(fgl.gl_pathv, fgl.gl_pathc, FALSE, root);
419: globfree(&dgl);
420: globfree(&fgl);
421: reread=FALSE;
422: dircur=dirbar=filecur=filebar=0;
423: while(!reread) {
424: hold_update=TRUE;
425: display_current_path(api, cfile);
426: api->lbclr=api->lclr|(api->bclr<<4);
427: api->list(WIN_NOBRDR|WIN_FIXEDHEIGHT|WIN_IMM|WIN_REDRAW,1,3,listwidth,&dircur,&dirbar,NULL,dir_list);
428: api->list(WIN_NOBRDR|WIN_FIXEDHEIGHT|WIN_IMM|WIN_REDRAW,1+listwidth+1,3,listwidth,&filecur,&filebar,NULL,file_list);
429: api->lbclr=lbclr;
430: lastfield=currfield;
431: fieldmove=0;
432: hold_update = FALSE;
433: switch(currfield) {
434: case DIR_LIST:
435: i=api->list(WIN_NOBRDR|WIN_FIXEDHEIGHT|WIN_EXTKEYS|WIN_UNGETMOUSE,1,3,listwidth,&dircur,&dirbar,NULL,dir_list);
436: if(i==-1) { /* ESC */
437: retval=fp->files=0;
438: goto cleanup;
439: }
440: if(i==-2-'\t') /* TAB */
441: fieldmove=1;
442: if(i==-3842) /* Backtab */
443: fieldmove=-1;
444: if(i==-2-CIO_KEY_MOUSE)
445: currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth, &dircur, &dirbar, &filecur, &filebar);
446: if(i>=0) {
447: FREE_AND_NULL(lastpath);
448: lastpath=strdup(cpath);
449: strcat(cpath,dir_list[i]);
450: reread=TRUE;
451: sprintf(cfile,"%s%s",cpath,cmsk);
452: }
453: break;
454: case FILE_LIST:
455: i=api->list(WIN_NOBRDR|WIN_FIXEDHEIGHT|WIN_EXTKEYS|WIN_UNGETMOUSE,1+listwidth+1,3,listwidth,&filecur,&filebar,NULL,file_list);
456: if(i==-1) {
457: retval=fp->files=0;
458: goto cleanup;
459: }
460: if(i>=0) {
461: sprintf(cfile,"%s%s",cpath,file_list[i]);
462: if((opts & UIFC_FP_MULTI)!=UIFC_FP_MULTI) {
463: retval=fp->files=1;
464: fp->selected=(char **)malloc(sizeof(char *));
465: if(fp->selected==NULL) {
466: fp->files=0;
467: retval=-1;
468: goto cleanup;
469: }
470: fp->selected[0]=strdup(cfile);
471: if(fp->selected[0]==NULL) {
472: FREE_AND_NULL(fp->selected);
473: fp->files=0;
474: retval=-1;
475: goto cleanup;
476: }
477: api->list(WIN_NOBRDR|WIN_FIXEDHEIGHT|WIN_IMM|WIN_REDRAW,1+listwidth+1,3,listwidth,&filecur,&filebar,NULL,file_list);
478: finished=reread=TRUE;
479: }
480: }
481: if(i==-2-'\t')
482: fieldmove=1;
483: if(i==-3842) /* Backtab */
484: fieldmove=-1;
485: if(i==-2-CIO_KEY_MOUSE)
486: currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth, &dircur, &dirbar, &filecur, &filebar);
487: break;
488: case CURRENT_PATH:
489: FREE_AND_NULL(tmplastpath);
490: tmplastpath=strdup(cpath);
491: api->getstrxy(SCRN_LEFT+2, SCRN_TOP+height-2, width-1, cfile, sizeof(cfile)-1, K_EDIT|K_TABEXIT|K_MOUSEEXIT, &i);
492: if(i==ESC) {
493: retval=fp->files=0;
494: goto cleanup;
495: }
496: if((opts & (UIFC_FP_FILEEXIST|UIFC_FP_PATHEXIST)) && !fexist(cfile)) {
497: FREE_AND_NULL(tmplastpath);
498: api->msg("No such path/file!");
499: continue;
500: }
501: if(isdir(cfile))
502: backslash(cfile);
503: _splitpath(cfile, drive, tdir, fname, ext);
504: sprintf(cpath,"%s%s",drive,tdir);
505: if(!isdir(cpath)) {
506: FREE_AND_NULL(tmplastpath);
507: api->msg("No such path!");
508: continue;
509: }
510: if(i==CIO_KEY_MOUSE)
511: currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth, &dircur, &dirbar, &filecur, &filebar);
512: if(i==3840)
513: fieldmove=-1;
514: else {
515: if(currfield == CURRENT_PATH)
516: fieldmove=1;
517: }
518: sprintf(cfile,"%s%s%s%s",drive,tdir,fname,ext);
519: if(strchr(fname,'*') !=NULL || strchr(fname,'?') !=NULL
520: || strchr(ext,'*') !=NULL || strchr(ext,'?') !=NULL
521: || (isdir(cfile) && !(opts & UIFC_FP_DIRSEL) && (i=='\r' || i=='\n'))
522: || (!isdir(cfile) && i!='\r' && i!='\n')) {
523: if(opts & UIFC_FP_MSKNOCHG) {
524: sprintf(cfile,"%s%s%s",drive,tdir,cmsk);
525: FREE_AND_NULL(tmplastpath);
526: api->msg("File mask cannot be changed");
527: continue;
528: }
529: else {
530: if(!isdir(cfile))
531: sprintf(cmsk, "%s%s", fname, ext);
532: reread=TRUE;
533: }
534: break;
535: }
536: else {
537: if((opts & UIFC_FP_MULTI)!=UIFC_FP_MULTI && (i=='\r' || i!='\n'))
538: fieldmove=0;
539: }
540: if((currfield != CURRENT_PATH) || fieldmove)
541: break;
542: if(isdir(cfile)) {
543: if((opts & UIFC_FP_MULTI)!=UIFC_FP_MULTI && i!='\t' && i != 3840) {
544: if(opts & UIFC_FP_DIRSEL) {
545: finished=reread=TRUE;
546: retval=fp->files=1;
547: fp->selected=(char **)malloc(sizeof(char *));
548: if(fp->selected==NULL) {
549: fp->files=0;
550: retval=-1;
551: goto cleanup;
552: }
553: fp->selected[0]=strdup(cfile);
554: if(fp->selected[0]==NULL) {
555: free(fp->selected);
556: fp->files=0;
557: retval=-1;
558: goto cleanup;
559: }
560: }
561: }
562: SAFECOPY(cpath, cfile);
563: backslash(cfile);
564: strcat(cfile,cmsk);
565: }
566: if(tmplastpath != NULL) {
567: if(strcmp(tmplastpath, cpath)) {
568: reread=TRUE;
569: FREE_AND_NULL(lastpath);
570: lastpath=tmplastpath;
571: tmplastpath=NULL;
572: }
573: }
574: FREE_AND_NULL(tmplastpath);
575: if((opts & UIFC_FP_MULTI)!=UIFC_FP_MULTI && i!='\t' && i!=3840) {
576: retval=fp->files=1;
577: fp->selected=(char **)malloc(sizeof(char *));
578: if(fp->selected==NULL) {
579: fp->files=0;
580: retval=-1;
581: goto cleanup;
582: }
583: fp->selected[0]=strdup(cfile);
584: if(fp->selected[0]==NULL) {
585: FREE_AND_NULL(fp->selected);
586: fp->files=0;
587: retval=-1;
588: goto cleanup;
589: }
590: finished=reread=TRUE;
591: }
592: break;
593: case MASK_FIELD:
594: p=strdup(cmsk);
595: api->getstrxy(SCRN_LEFT+8, SCRN_TOP+height-3, width-7, cmsk, sizeof(cmsk)-1, K_EDIT|K_TABEXIT|K_MOUSEEXIT, &i);
596: if(i==CIO_KEY_MOUSE)
597: currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth, &dircur, &dirbar, &filecur, &filebar);
598: if(i==ESC) {
599: retval=fp->files=0;
600: goto cleanup;
601: }
602: if(strcmp(cmsk, p)) {
603: sprintf(cfile,"%s%s",cpath,cmsk);
604: reread=TRUE;
605: }
606: FREE_AND_NULL(p);
607: if(i==3840)
608: fieldmove=-1;
609: else
610: fieldmove=1;
611: break;
612: }
613: currfield+=fieldmove;
614: if(currfield<0)
615: currfield=FIELD_LIST_TERM-1;
616: while(1) {
617: if(currfield==MASK_FIELD && (opts & UIFC_FP_MSKNOCHG)) {
618: currfield+=fieldmove;
619: continue;
620: }
621: if(currfield==CURRENT_PATH && !(opts & UIFC_FP_ALLOWENTRY)) {
622: currfield+=fieldmove;
623: continue;
624: }
625: break;
626: }
627: if(currfield==FIELD_LIST_TERM)
628: currfield=DIR_LIST;
629: }
630: free_opt_list(&file_list);
631: free_opt_list(&dir_list);
632: if(finished) {
633: if((opts & UIFC_FP_OVERPROMPT) && fexist(cfile)) {
634: if(api->list(WIN_MID|WIN_SAV, 0,0,0, &i, NULL, "File exists, overwrite?", YesNo)!=0)
635: finished=FALSE;
636: }
637: if((opts & UIFC_FP_CREATPROMPT) && !fexist(cfile)) {
638: if(api->list(WIN_MID|WIN_SAV, 0,0,0, &i, NULL, "File does not exist, create?", YesNo)!=0)
639: finished=FALSE;
640: }
641: }
642: }
643:
644: cleanup: /* Cleans up allocated variables returns from function */
1.1.1.2 ! root 645: hold_update=oldhu;
! 646: gotoxy(oldx,oldy);
1.1 root 647: FREE_AND_NULL(lastpath);
648: FREE_AND_NULL(tmppath);
649: FREE_AND_NULL(tmplastpath);
650: free_opt_list(&file_list);
651: free_opt_list(&dir_list);
652: return(retval);
653: }
654:
655: int filepick_free(struct file_pick *fp)
656: {
657: int i;
658:
659: for(i=0; i<fp->files; i++) {
660: FREE_AND_NULL(fp->selected[i]);
661: }
662: FREE_AND_NULL(fp->selected);
663: return(0);
664: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.