home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:12939 comp.os.msdos.programmer:8867
- Path: sparky!uunet!mcsun!uknet!glasgow!unix.brighton.ac.uk!amn
- From: amn@unix.brighton.ac.uk (Anthony Naggs)
- Newsgroups: comp.lang.c,comp.os.msdos.programmer
- Subject: Re: WANTED: Code to search DOS directory/subdirectories
- Message-ID: <1992Aug28.235022.19246@unix.brighton.ac.uk>
- Date: 28 Aug 92 23:50:22 GMT
- References: <1992Aug27.044445.22165@uwm.edu>
- Reply-To: amn@vms.brighton.ac.uk
- Organization: University of Brighton, England
- Lines: 57
-
- Robert C Allender, <rca@csd4.csd.uwm.edu>, asked a number of questions:
- > 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. I had what I thought was a good
- > source listing in the C User's Journal - February 1992 edition, but it won't
- > compile to save my life. Has anyone else tried this code?
-
- I can't comment, as my copy is somewhere amongst all the other mags under
- the desk. The example you give looks okay.
-
- > { ...
- >
- > struct find_t ffblk;
- > int done;
- > printf("Directory of C:\\\n");
- > done = _dos_findfirst("C:\\*.*",_A_SUBDIR,&ffblk);
- > while(!done)
- > {
- > printf(" %s\n", ffblk.name);
- > done = _dos_findnext(&ffblk);
- > }
- > return 0;
- >
- > } ...
- >
- > the _A_SUBDIR is supposed to return only DOS subdirectory entries, however it
- > seems to (as do the other alternatives) also return normal files that are in
- > the same directory with the directory entries.
-
- There are many books which state this, they are *wrong*. As far as I remember,
- (hedging a little), the attribute bits in the search mask have the following
- effects:
- Microsoft C names Value Effect
- _A_NORMAL 0x00 Find files with _A_RDONLY or _A_ARCH set
- _A_RDONLY 0x01 None (read-only files are found anyway)
- _A_HIDDEN 0x02 Also find Hidden files
- _A_SYSTEM 0x04 Also find System files
- _A_VOLID 0x08 Also find the volume label, (if present in search
- directory) [see note below]
- _A_SUBDIR 0x10 Also find Subdirectories
- _A_ARCH 0x20 None (new, 'Archive', files are found anyway)
-
- Note:
- * If _A_VOLID is the only bit set, then the search will only look in the
- root directory for the Volume label. (The standard method of finding the
- volume label is to do an extended FCB search with just this attribute).
-
- To only find subdirectories, for example, you would have to include them in
- your search and then test the attributes of each file found.
-
- > If anyone can help, I'd really appreciate it.
-
- Hope this is useful, Anthony Naggs
-
- Software/Electronics Engineer P O Box 1080, Peacehaven
- East Sussex BN10 8PZ
- Phone: +44 273 589701 Great Britain
- Email, (c/o Univ of Brighton): amn@vms.brighton.ac.uk
-