home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 8835 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  2.1 KB

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