home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12939 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  2.9 KB

  1. Xref: sparky comp.lang.c:12939 comp.os.msdos.programmer:8867
  2. Path: sparky!uunet!mcsun!uknet!glasgow!unix.brighton.ac.uk!amn
  3. From: amn@unix.brighton.ac.uk (Anthony Naggs)
  4. Newsgroups: comp.lang.c,comp.os.msdos.programmer
  5. Subject: Re: WANTED: Code to search DOS directory/subdirectories
  6. Message-ID: <1992Aug28.235022.19246@unix.brighton.ac.uk>
  7. Date: 28 Aug 92 23:50:22 GMT
  8. References: <1992Aug27.044445.22165@uwm.edu>
  9. Reply-To: amn@vms.brighton.ac.uk
  10. Organization: University of Brighton, England
  11. Lines: 57
  12.  
  13. Robert C Allender, <rca@csd4.csd.uwm.edu>, asked a number of questions:
  14. > I'm trying to find a reasonable block of code that will search through a DOS
  15. > directory using Turbo C 3.0 in DOS mode.  I had what I thought was a good
  16. > source listing in the C User's Journal - February 1992 edition, but it won't
  17. > compile to save my life.  Has anyone else tried this code?
  18.  
  19. I can't comment, as my copy is somewhere amongst all the other mags under
  20. the desk.  The example you give looks okay.
  21.  
  22. >      { ...
  23. >
  24. >        struct find_t ffblk;
  25. >        int done;
  26. >        printf("Directory of C:\\\n");
  27. >        done = _dos_findfirst("C:\\*.*",_A_SUBDIR,&ffblk);
  28. >        while(!done)
  29. >        {
  30. >           printf(" %s\n", ffblk.name);
  31. >           done = _dos_findnext(&ffblk);
  32. >        }
  33. >        return 0;
  34. >
  35. >      } ...
  36. >
  37. > the _A_SUBDIR is supposed to return only DOS subdirectory entries, however it
  38. > seems to (as do the other alternatives) also return normal files that are  in
  39. > the same directory with the directory entries.
  40.  
  41. There are many books which state this, they are *wrong*.  As far as I remember,
  42. (hedging a little), the attribute bits in the search mask have the following
  43. effects:
  44. Microsoft C names   Value   Effect
  45.     _A_NORMAL       0x00    Find files with _A_RDONLY or _A_ARCH set
  46.     _A_RDONLY       0x01    None (read-only files are found anyway)
  47.     _A_HIDDEN       0x02    Also find Hidden files
  48.     _A_SYSTEM       0x04    Also find System files
  49.     _A_VOLID        0x08    Also find the volume label, (if present in search
  50.                             directory) [see note below]
  51.     _A_SUBDIR       0x10    Also find Subdirectories
  52.     _A_ARCH         0x20    None (new, 'Archive', files are found anyway)
  53.  
  54. Note:
  55. *   If _A_VOLID is the only bit set, then the search will only look in the
  56.     root directory for the Volume label.  (The standard method of finding the
  57.     volume label is to do an extended FCB search with just this attribute).
  58.  
  59. To only find subdirectories, for example, you would have to include them in
  60. your search and then test the attributes of each file found.
  61.  
  62. > If anyone can help, I'd really appreciate it.
  63.  
  64. Hope this is useful, Anthony Naggs
  65.  
  66. Software/Electronics Engineer                   P O Box 1080, Peacehaven
  67.                                                 East Sussex  BN10 8PZ
  68. Phone: +44 273 589701                           Great Britain
  69. Email, (c/o Univ of Brighton): amn@vms.brighton.ac.uk
  70.