home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18299 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  1.4 KB

  1. Path: sparky!uunet!usc!wupost!spool.mu.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
  2. From: torek@horse.ee.lbl.gov (Chris Torek)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: curses.h dirent.h
  5. Date: 14 Dec 1992 03:09:36 GMT
  6. Organization: Lawrence Berkeley Laboratory, Berkeley CA
  7. Lines: 20
  8. Distribution: usa
  9. Message-ID: <27966@dog.ee.lbl.gov>
  10. References: <ByzE2M.3vH@ns1.nodak.edu> <Ef9Yx2i00WB=A3GkIJ@andrew.cmu.edu>
  11. NNTP-Posting-Host: 128.3.112.15
  12.  
  13. (Note that dirent.h is a POSIX thing, not a C thing.  Similarly,
  14. discussion about stat() belongs elsewhere.  This correction goes to
  15. comp.lang.c only because the article quoted below was posted there.)
  16.  
  17. In article <Ef9Yx2i00WB=A3GkIJ@andrew.cmu.edu> Tod McQuillin
  18. <tm8t+@andrew.cmu.edu> writes:
  19. >      if (statbuf.st_mode & S_IFDIR) /* Is it a directory? */
  20.  
  21. The `file type' in a stat `st_mode' field is not a set of individual
  22. bits, but rather a number.  This is something like testing the bit
  23. (1<<2) to see if a value equals four: it will give false positives.
  24. The Official POSIX Method is to use S_ISDIR(statbuf.st_mode).  The
  25. Classic Unix method is ((statbuf.st_mode & S_IFMT) == S_IFDIR); the
  26. test quoted above happens to give false positives for block devices
  27. and sockets on traditional Unix boxes.
  28.  
  29. We now return you to appropriate comp.lang.c material (I hope) :-) .
  30. -- 
  31. In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
  32. Berkeley, CA        Domain:    torek@ee.lbl.gov
  33.