void createTestFiles(void) { Dsetdrv(drive); // switch to selected drive Dsetpath("\\"); (void) Dcreate("TESTDIR"); Dsetpath("\\TESTDIR"); int i, f; char numString[8]; char fileName[16]; for(i=0; i<25; i++) { byteToHex(i + 1, numString); strcpy(fileName, "FILE_"); strcat(fileName, numString); f = Fcreate(fileName, 0); Fwrite(f, 7, fileName); Fclose(f); strcpy(fileName, "FILENAME.X"); strcat(fileName, numString); f = Fcreate(fileName, 0); Fwrite(f, 12, fileName); Fclose(f); strcpy(fileName, "DIR_"); strcat(fileName, numString); (void) Dcreate(fileName); } }
/******************************************************************************* Test if a folder exists *******************************************************************************/ int _dexist(char *name) { char old_path[FILENAME_MAX]; char myname[FILENAME_MAX]; int old_drv; int i,ok=FALSE; DTA *old,dta; old=Fgetdta(); old_drv=Dgetdrv(); Dgetpath(old_path,1+old_drv); if (name[1]==':') Dsetdrv((int)name[1]-65); Fsetdta(&dta); strcpy(myname,name); i=(int)strlen(myname); if (myname[i-1]=='\\') strcat(myname,"*.*"); else strcat(myname,"\\*.*"); if (!Fsfirst(myname,FA_READONLY+FA_HIDDEN+FA_SYSTEM+FA_ARCHIVE+FA_SUBDIR)) ok=TRUE; Dsetdrv(old_drv); Dsetpath(old_path); Fsetdta(old); return ok; }
int x_setpath(const char *path) { #if USE_gemdos return xerror((int) gemdos(59, path)); #else return xerror(Dsetpath(path)); #endif }
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 */
static void setSpoolPath(void) { if (spoolDir) { if (spoolDir[0] != '\0' && spoolDir[1] == ':') { /* drive spec? */ Dsetdrv(tolower(spoolDir[0]) - 'a'); } if (Dsetpath(spoolDir) < 0) { uiPrintf(uiH, uiPrERR, "set path|>%s<", spoolDir); } } } /* setSpoolPath */
WORD count( char *s ) { char *tmp; int ret; tmp = s; while ( *tmp++ ); if (*(tmp-2) == '*') /* a dir */ { if ( set_dir( s ) ) /* set the path */ { ret = countrec(); Dsetpath( "\\" ); return( ret ); /* recursive count */ } else return( FALSE ); } numfiles++; return(TRUE); }
/******************************************************************************* Test if a file exists *******************************************************************************/ int _fexist(char *name,DTA *res) { char old_path[FILENAME_MAX]; int old_drv; int ok=FALSE; DTA *old,dta; old=Fgetdta(); old_drv=Dgetdrv(); Dgetpath(old_path,1+old_drv); if (name[1]==':') Dsetdrv((int)name[1]-65); Fsetdta(&dta); if (!Fsfirst(name,FA_READONLY+FA_HIDDEN+FA_SYSTEM+FA_ARCHIVE+FA_SUBDIR)) ok=TRUE; if (ok && res) memcpy((void *)res,(void *)&dta,sizeof(DTA)); Dsetdrv(old_drv); Dsetpath(old_path); Fsetdta(old); return ok; }
/******************************************************************************* BALAYAGE D'UN DOSSIER *******************************************************************************/ static int Balaie_Path(char *directory,int wx,int wy,int ww,int wh) { char old_path[FILENAME_MAX]; int old_drv; char pfn[FILENAME_MAX]; DTA *mydta; int i,Fin=0; int cnt,pos; /* long count;*/ t2=0; old_drv=Dgetdrv(); Dgetpath(old_path,1+old_drv); mydta=Fgetdta(); if (directory[1]==':') Dsetdrv((int)directory[1]-65); strcpy(pfn,directory); strcat(pfn,"\\*.*"); if (glb.opt.sl_rec) i=Fsfirst(pfn,FA_READONLY|FA_SUBDIR|FA_ARCHIVE); else i=Fsfirst(pfn,FA_READONLY|FA_ARCHIVE); pos=0; loop1: cnt=0; while (!i) { cnt+=1; if (mydta->d_fname[0]!='.' && cnt>pos) { strcpy(pfn,directory); strcat(pfn,"\\"); strcat(pfn,mydta->d_fname); if (mydta->d_attrib&FA_SUBDIR) { pos=cnt; if (Balaie_Path(pfn,wx,wy,ww,wh)) return TRUE; strcpy(pfn,directory); strcat(pfn,"\\*.*"); if (glb.opt.sl_rec) i=Fsfirst(pfn,FA_READONLY|FA_SUBDIR|FA_ARCHIVE); else i=Fsfirst(pfn,FA_READONLY|FA_ARCHIVE); goto loop1; } } if (Kbshift(-1)!=shift) return TRUE; i=Fsnext(); /* if (i!=0) { time(&t1); if(glb.opt.sl_pause) { count=1000L*max( 0 , (long)glb.opt.sl_ptime - (t1-t2) ); evnt_timer( (int)(count&0xFFFFUL),(int)(count>>16) ); } else count=0; } */ } strcpy(pfn,directory); strcat(pfn,"\\"); strcat(pfn,glb.opt.sl_name); if (glb.opt.sl_rec) i=Fsfirst(pfn,FA_READONLY|FA_SUBDIR|FA_ARCHIVE); else i=Fsfirst(pfn,FA_READONLY|FA_ARCHIVE); pos=0; cnt=0; while (!i) { cnt+=1; if (mydta->d_fname[0]!='.' && cnt>pos) { strcpy(pfn,directory); strcat(pfn,"\\"); strcat(pfn,mydta->d_fname); if (!(mydta->d_attrib&FA_SUBDIR)) affiche(pfn,wx,wy,ww,wh); } if (Kbshift(-1)!=shift) return TRUE; i=Fsnext(); /* if (i!=0) { time(&t1); if(glb.opt.sl_pause) count=1000L*max( 0 , (long)glb.opt.sl_ptime - (t1-t2) ); else count=0; evnt_timer( (int)(count&0xFFFFUL),(int)(count>>16) ); } */ } Dsetdrv(old_drv); Dsetpath(old_path); return Fin; }
WORD countrec( VOID ) { /* char *saved; */ DMABUFFER *dumb, *saved; REG int retmsg; dumb = (DMABUFFER *)malloc( (LONG)sizeof(DMABUFFER) ); if ( !dumb ) { do1_alert( STFO8DEE ); return( FALSE ); } retmsg = TRUE; saved = (DMABUFFER *)Fgetdta(); /* save the current dta */ Fsetdta( dumb ); if (!Fsfirst(curall, 0x37)) { do { if (dumb->d_fname[0] != HOME) { if (SUBDIR & dumb->d_fattr) { /* setpath to one more down */ if (Dsetpath(dumb->d_fname)) { retmsg = FALSE; goto endrec; } numdirs++; if ( ++f_level > COPYMAXDEPTH ) { do1_alert( STFO8DEE ); retmsg = FALSE; goto endrec; } if (!countrec()) /* to the recursion setpath to one back */ { retmsg = FALSE; goto endrec; } f_level--; if (Dsetpath(baklvl)) { retmsg = FALSE; goto endrec; } } else { numfiles++; /* add up the file count and size */ tolsize += dumb->d_fsize; } } } while (!Fsnext()); } endrec: Fsetdta( saved ); /* reset the dta */ free( dumb ); return(retmsg); }
int chkdf( char *str, int flag ) { REG int ret; int first,change; int ret1; first = TRUE; change = f_rename; if ( flag == CPFILE ) { if ( f_rename ) goto cc_3; if ( write_save ) /* overwrite existing file */ return( OK ); cc_1: if ( (ret = (WORD)Fopen(fixdst, 0)) >= 0 ) { /* file exist */ Fclose( ret ); cc_3: ret = edname( str, CPFILE, change ); if ( ret == CHECK ) { if ( f_rename ) /* do rename */ { /* first = FALSE; */ change = FALSE; goto cc_1; } } return( ret ); } } else { if ( f_rename ) /* if rename then show box first */ goto cc_5; cc_6: Dsetdrv(*fixdst - 'A'); if ( !( ret = (WORD)Dsetpath( fixdst + 2 ) ) ) /* direcory exist */ { cc_5: ret1 = edname( str, CPDIR, change ); /* update name conflict box */ change = FALSE; if ( ( ret1 == CHECK ) || /* user enter new name */ ( ( ret1 == COPY ) && f_rename && first ) ) { first = FALSE; goto cc_6; } return( ret1 ); } } /* 0xFFDE: path not found. 0xFFDF: file not found. */ return (((ret == EFILNF)||(ret == EPTHNF))? OK:FALSE); }