void modify_fname() { int button; char f_path[200], f_file[32], ext[] = "\\*.*"; strncpy (f_path, path, 200); f_path[196] = '\0'; if (strrchr (f_path, '\\')) { strcpy (strrchr (f_path, '\\'), ext); strncpy (f_file, strrchr (path, '\\') + 1, 32); f_file[31] = '\0'; } else { strcat (strrchr (path, '\\'), ext); f_file[0] = '\0'; } if (_GemParBlk.global[0] >= 0x0140) fsel_exinput (f_path, f_file, & button, "Choose Log File"); else fsel_input (f_path, f_file, &button); if (button == 0) return; strncpy (path, f_path, 250); if (strrchr (path, '\\')) strncpy (strrchr (path, '\\') + 1, f_file, 32); else strcat (strrchr (path, '\\'), f_file); create_path(); }
void selectDestinationDir(void) { short button; char path[256], fname[256]; memset(path, 0, 256); memset(fname, 0, 256); strcpy(path, "C:\\*.*"); BYTE drive = getLowestDrive(); // get the lowest HDD letter and use it in the file selector path[0] = drive; graf_mouse(M_ON, 0); fsel_input(path, fname, &button); // show file selector graf_mouse(M_OFF, 0); if(button != 1) { // if OK was not pressed return; } removeLastPartUntilBackslash(path); // remove part behind the last separator (most probably wild card) destDir.isSet = 1; strcpy(destDir.path, path); // copy in the destination dir }
WORD get_file(WORD label) { WORD butn, ii; BYTE tmp_path[64], tmp_name[13]; if ( !sav_rcspath[0] ) get_defpath(tmp_path, "*.RSC"); else strcpy(tmp_path, sav_rcspath); tmp_name[0] = '\0'; #if GEMDOS if (Sversion() >= 0x0140) { LONG fs_label; fs_label = string_addr(label); fsel_exinput(ADDR(&tmp_path[0]), ADDR(&tmp_name[0]), &butn, (BYTE FAR *)fs_label); } else #endif fsel_input(ADDR(&tmp_path[0]), ADDR(&tmp_name[0]), &butn); graf_mouse(rcs_mform, 0x0L); if (butn) { if (!tmp_name[0]) if (hndl_alert(1, string_addr(NOFNAME)) == 1) return(FALSE); if (strcmp(sav_rcspath, tmp_path)) { #if GEMDOS Dsetpath((const char *)ADDR(tmp_path)); #else dos_chdir(ADDR(tmp_path)); #endif strcpy(sav_rcspath, tmp_path); } strcpy(rcs_rfile, &tmp_path[0]); for (ii = 0; rcs_rfile[ii] && rcs_rfile[ii] != '*'; ii++) ; rcs_rfile[ii - 1] = NULL; /* knock off slash */ strcat(rcs_rfile, "\\"); strcpy(&rsc_path[1], rcs_rfile); rsc_path[0] = strlen(rcs_rfile); strcat(rcs_rfile, &tmp_name[0]); /* Force 'rsc' extension on resource file.*/ r_to_xfile(rcs_rfile, "RSC"); r_to_xfile(rcs_dfile, "DFN"); return (TRUE); } /* if butn */ else return (FALSE); } /* get_file */
VOID hndl_spbut(WORD ob) { BYTE *pstr; WORD isok; WORD i, j, k, remvd_1st, isgrafic; WORD exists; BYTE dir[ 80 ]; BYTE new_wc[ 14 ]; BYTE new_file[ 14 ]; BYTE dir_wc[ 80 ]; if ( ob == ADDNAME ) { strcpy(&gl_fname[0], ""); fsel_input(ADDR(&gl_fspec[0]), ADDR(&gl_fname[0]), &isok); strcpy( dir_wc, gl_fspec ); strcpy( new_file, gl_fname ); splt_dir( dir_wc, dir, new_wc ); exists = file_exists( dir, new_file ); if ( exists ) { if ( (isok) && (gl_fname[0]) && (gl_fspec[0]) ) { strcpy(&gl_fspol[0], &gl_fspec[0]); pstr = &gl_fspol[0]; while (*pstr) pstr++; pstr--; while ( (*pstr) && (*pstr != '\\') && (*pstr != ':') ) pstr--; if (*pstr) pstr++; strcpy(pstr, &gl_fname[0]); if ( istext( &gl_fname[0] ) ) hndl_spmsg((WORD)strlen(&gl_fspol[0]), (LONG)ADDR(&gl_fspol[0]), 1, FALSE, 0); else { form_alert(1, ADDR("[1][The Print Spooler is only able to|\ directly print text files. If you wish|\ to print a graphic file in background,|\ go to the OUTPUT application, and select|\ the Print in Background option.][ OK ]") ); } } }
/******************************************************************************* _fselect ******************************************************************************** int _fselect(char *pfname,char *pname,char *fname,char *ext,char *title) Funktion: Ruft den FileSelector in komfortabler Art und Weise auf. Dabei kann man alle Parts (Filename, Pathname, etc.) einzeln �bergeben. Man kann aber auch Pathname und den kompletten Namen in `pfname' �bergeben. Diese Routine sucht sich schon das, was ihr fehlt in bestimmten Grenzen selbst heraus. Diese Funktion unterst�tzt den FSEL-Cookie und l�uft auch ohne Selectric. Parameter: *pfname Enth�lt abschlie�end den fertigen Pfad, den man sofort in ein `open' einsetzen kann. *pname Der Startpfad (ohne Wildcards!). *fname Ein voreingestellte Filenamen. *ext Eine Extension. *title Einen Boxtitel. Dabei wird a) die TOS-Version als auch der FSEL-Cookie �berpr�ft. Return: Der Button mit dem der Selector verlassen wurde. Bemerkung: Beim Aufruf aus Accessories nicht vergessen ein BEG/END_UPDATE um diesen Aufruf zu legen!!!!!!!!!! Die meisten File-Selector Clones (incl. Selectric) machen das eh, nicht aber das Original ... *******************************************************************************/ int _fselect(char *pfname,char *pname,char *fname,char *ext,char *title) { int but; char *p; if (!fname[0]) { p=strrchr(pfname,'\\'); if (p) strcpy(fname,p+1); else strcpy(fname,pfname); } if (!pname[0]) { p=strrchr(pfname,'\\'); if (p) { p[1]='\0'; strcpy(pname,pfname); } } else if (pname[strlen(pname)-1] != '\\') strcat(pname,"\\"); strcat(pname,ext); wind_update(BEG_MCTRL); form_dial(FMD_START,0,0,0,0,glb.aes.desk.x,glb.aes.desk.y,glb.aes.desk.w,glb.aes.desk.h); if (_fsel_check() || (_vTOS() >= 0x0104)) fsel_exinput(pname,fname,&but,title); else fsel_input(pname,fname,&but); form_dial(FMD_FINISH,0,0,0,0,glb.aes.desk.x,glb.aes.desk.y,glb.aes.desk.w,glb.aes.desk.h); _clearAesBuffer(); wind_update(END_MCTRL); p=strrchr(pname,'\\'); if (p) *p='\0'; strcpy(pfname,pname); strcat(pfname,"\\"); strcat(pfname,fname); return but; }
/* ----------------- */ int fsel(char *st_path, char *ext) { char path[80], file[14]; int st, button; strcpy( path, st_path ); strcpy( rindex(path, '\\') + 1, "*" ); strcat( path, ext ); strcpy( file, rindex(st_path, '\\') + 1 ); st = fsel_input(path, file, &button); if (button) { strcpy(st_path, path); strcpy(rindex(st_path, '\\') + 1, file); } if (button & st) return(TRUE); else return(FALSE); }
void save_conf( int timeout ) { OBJECT *tree = rs_object; char *ppath, *endpath, *qpath, *pfsel; char *alert = (char *)rs_frstr[SAVELERT]; char path[128],file[14]; int ret, button; /* get filename from alert */ endpath = ppath = savepath; while( *(++endpath) != '?'); /* find out what user wants to do */ ret = form_alert( 1, alert ); /* Cancel */ if( ret == 3 ) return; /* Locate */ if( ret == 2 ) { qpath = ppath; pfsel = path; while( *qpath != 'M' ) *pfsel++ = *qpath++; *pfsel++ = '*'; *pfsel++ = '.'; *pfsel++ = '*'; *pfsel++ = 0; file[0] = 0; ret = fsel_input( path, file, &button ); if( ret < 0 ) { saverr: form_alert( 1, (char *)rs_frstr[SAVERR] ); if( !*endpath ) *endpath = '?'; return; } if( !button ) return; pfsel = path; qpath = file; while( *(++pfsel) ); while( *(--pfsel) != '\\' ); while( *qpath ) *(++pfsel) = *qpath++; *(++pfsel) = 0; ppath = path; } if( ret == 1 ) { *endpath = 0; } ret = (int)Fopen( ppath, 0 ); if( ret < 0 ) goto saverr; if( Fread(ret, sizeof(struct MA_FILE), &mafile) != sizeof(struct MA_FILE) || mafile.magic != 0x601a || mafile.minfo.cookie != COOKIE ) { Fclose( ret ); goto saverr; } mafile.minfo.udset = ma_info->udset; mafile.minfo.linear = ma_info->linear; if( IsSelected(MODEM) ) mafile.minfo.watch = 1; else mafile.minfo.watch = 0; if( ma_info->stacy ) { mafile.minfo.stacy = 1; if( IsSelected(SWITCH) ) { mafile.minfo.stacmask |= SH_SCREEN; } else { mafile.minfo.stacmask &= ~SH_SCREEN; } if( IsSelected(LITE) ) { mafile.minfo.stacmask |= SH_LIGHT; } else { mafile.minfo.stacmask &= ~SH_SCREEN; } } else mafile.minfo.stacy = mafile.minfo.stacmask = 0; /* save the park time for Leonard */ mafile.minfo.savepark = (parktime >= 0) ? parktime : 0; mafile.minfo.timeout = timeout * 3600; mafile.flags |= 7; Fseek( 0L, ret, 0 ); button = (int)Fwrite( ret, sizeof(struct MA_FILE), &mafile ); Fclose( ret ); if( button != (int)sizeof(struct MA_FILE) ) goto saverr; else if( !*endpath ) *endpath = '?'; }
int open_file( WX **pwx, int *pvw, int *pvh ) { WX *wx; char file[14], *ppath; int i, ret; DTA mydta, *savedta; long readamt; char *readbuf; if( (wx = calloc( 1L, sizeof(WX) )) == NULL ) { return (int)ENSMEM; } wx->name[0] = (char)Dgetdrv() + 'A'; wx->name[1] = ':'; Dgetpath( &(wx->name[2]), 0 ); strcat( wx->name, "\\*.*" ); file[0] = 0; ret = fsel_input( wx->name, file, &i ); if( ret != 1 ) { goto err1; } else if( !i ) { ret = (int)ERROR; goto err1; } if( (ppath = strrchr( wx->name, '\\' )) == NULL ) ppath = wx->name; else ++ppath; strcpy( ppath, file ); savedta = Fgetdta(); Fsetdta( &mydta ); Fsfirst( wx->name, 1 ); Fsetdta( savedta ); if( (readbuf = (char *)Malloc(mydta.d_length)) <= NULL ) { ret = (int)ENSMEM; goto err1; } if( (ret = (int)Fopen(wx->name, 0)) < 0 ) goto err; graf_mouse( BUSYBEE, NULL ); readamt = Fread( ret, mydta.d_length, readbuf ); graf_mouse( ARROW, NULL ); Fclose( ret ); if( readamt != mydta.d_length ) { ret = (int)readamt; err: Mfree( readbuf ); err1: free( wx ); return ret; } wx->tabs = 4 * form_alert( 1, "[2][ What size tabs? ][ 4 | 8 ]" ); graf_mouse( BUSYBEE, NULL ); ret = parse_buf( readbuf, readamt, wx->tabs, &wx->line0, pvw, pvh ); graf_mouse( ARROW, NULL ); Mfree( readbuf ); if( ret != E_OK ) { free_tlines( wx->curline ); goto err1; } *pwx = wx; return ret; }