home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!sample.eng.ohio-state.edu!purdue!mentor.cc.purdue.edu!pf@bilbo.bio.purdue.edu
- From: pf@bilbo.bio.purdue.edu (Paul Furbacher)
- Newsgroups: comp.os.msdos.programmer
- Subject: Re: WANTED: Code to search DOS directory/subdirectories
- Message-ID: <BtMqnB.9J0@mentor.cc.purdue.edu>
- Date: 27 Aug 92 06:42:46 GMT
- References: <1992Aug27.044445.22165@uwm.edu>
- Sender: news@mentor.cc.purdue.edu (USENET News)
- Distribution: comp.os.msdos.programmer
- Organization: Purdue University
- Lines: 47
-
- In article <1992Aug27.044445.22165@uwm.edu>,
- rca@csd4.csd.uwm.edu (Robert C Allender) writes:
- >
- > I'm trying to find a reasonable block of code that will search through a DOS
- > directory using Turbo C 3.0 in DOS mode.
-
- It appears that you took the following from the TC manual, yet there is at
- least one important mistake.
- > eg.
- >
- > { ...
- >
- > struct find_t ffblk;
- > int done;
- > printf("Directory of C:\\\n");
- > done = _dos_findfirst("C:\\*.*",_A_SUBDIR,&ffblk);
-
- The above line has the structure and attribute parameters transposed.
- Is the rest okay? (I'll leave that to you.)
-
- > while(!done)
- > {
- > printf(" %s\n", ffblk.name);
- > done = _dos_findnext(&ffblk);
- > }
- > return 0;
- >
- > } ...
-
- Next, you wrote...
-
- > the _A_SUBDIR is supposed to return only DOS subdirectory entries, however it
- > seems to (as do the other alternatives) also return normal files ...
-
- I might be wrong, but it seems that it has been said many times before that
- findfirst() and findnext() find all "normal" files *and* the ones
- specified by the attribute value. (The manual doesn't say that though.)
- At least that's how they worked last time I used them (but that was in TP).
- What you'll have to do is filter out the "regular" files by
- "if (ffblk.ff_attrb && FA_DIREC)..."
- or something like that (it's been a while since I talked C).
-
- Since I never took a course in C (learned it in between the real
- stuff I'm supposed to be doing for a living so I could do that stuff
- better), why the underscored prefixes, such as _dos_ ?
-
- PF
-