Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!dimacs.rutgers.edu!rutgers!sun-barr!apple!usc!samsung!rex!uflorida!reef.cis.ufl.edu!scroll From: scroll@reef.cis.ufl.edu (Steve Croll) Newsgroups: comp.sys.amiga.programmer Subject: Re: Need help w/SAS dfind(), dnext() Message-ID: <26568@uflorida.cis.ufl.EDU> Date: 29 Jan 91 20:57:07 GMT References: <18173@brahms.udel.edu> Sender: news@uflorida.cis.ufl.EDU Distribution: na Organization: UF CIS Dept. Lines: 85 In article <18173@brahms.udel.edu> don@brahms.udel.edu (Donald R Lloyd) writes: > > Anyway, I'm having trouble with dfind() and dnext(). [stuff deleted] >... can someone give me a working example of how I should be going about it? > I found an old (short) program that uses dfind() and dnext(). It is probably not bulletproof but should illustrate the above functions. #include void PrintDosError(int error); char path[FMSIZE]; int main(int argc, char *argv[]) { int error; struct FILEINFO *info; int index, size; if (argc == 1) { printf("usage: %s \n",argv[0]); exit(10); } info = (struct FILEINFO *)malloc(sizeof(struct FILEINFO)); if (info == NULL) { printf("No memory.\n"); exit(10); } for (index = 1; index < argc; index++) { printf("\nMatching: %s\n",argv[index]); printf("--------------------------\n"); size = stcgfp(path,argv[index]); error = dfind(info,argv[index],1); while (error == 0) { if (size != 0) { printf("%s",path); if (path[size-1] != ':') printf("/"); } printf("%s",&(info->fib_FileName)); if (info->fib_DirEntryType > 0) printf(" (dir)\n"); else printf("\n"); error = dnext(info); } if ( _OSERR != 0) { PrintDosError(_OSERR); printf("%s\n",argv[index]); } } return 0; } void PrintDosError(int error) { extern int os_nerr; int index = 0; while (os_errlist[index].err_no <= os_nerr) { if (os_errlist[index].err_no == error) { printf("%s: ",os_errlist[index].msg); return; } index++; } printf("Unknown DOS Error: "); } -- -- Steve Croll (internet: scroll@reef.cis.ufl.edu home: 904-373-8389)