home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / analg211.zip / macdir.h < prev    next >
C/C++ Source or Header  |  1997-03-14  |  2KB  |  60 lines

  1. /*
  2.  *      Directory Operations for Mac based on BSD 4.3   <macdir.h>
  3.  *      By Jason Linhart, January 1997
  4.  */
  5.  
  6. #ifndef _MACDIR_H
  7. #define _MACDIR_H       1
  8.  
  9. #define NAME_MAX                255             /* # chars in a file name */
  10.  
  11. typedef long off_t;
  12.  
  13. struct dirent {
  14. #ifdef COMMENT
  15.         long            d_ino;
  16.         off_t           d_off;
  17.         unsigned short  d_reclen;
  18. #endif
  19.         char            d_name[NAME_MAX+1];
  20. };
  21.  
  22. /* The internal is hidden from the user. */
  23. typedef void DIR;
  24.  
  25. /* Open a directory stream on NAME.
  26.    Return a DIR stream on the directory, or NULL if it could not be opened.  */extern DIR *opendir (const char *name);
  27.  
  28. /* Close the directory stream DIRP.
  29.    Return 0 if successful, -1 if not.  */
  30. extern int closedir (DIR * dirp);
  31.  
  32. /* Read a directory entry from DIRP.
  33.    Return a pointer to a `struct dirent' describing the entry,
  34.    or NULL for EOF or error.  The storage returned may be overwritten
  35.    by a later readdir call on the same DIR stream.  */
  36. extern struct dirent *readdir (DIR * dirp);
  37.  
  38. /* Rewind DIRP to the beginning of the directory.  */
  39. extern void rewinddir (DIR * dirp);
  40.  
  41. /* Seek to position POS on DIRP.  */
  42. extern void seekdir (DIR * dirp, off_t pos);
  43.  
  44. /* Return the current position of DIRP.  */
  45. extern off_t telldir (DIR * dirp);
  46.  
  47. /* Fake stat to work with current directory entry */
  48.  
  49. #define stat(file_name,buf)             dirstat(file_name,buf)
  50.  
  51. struct stat {
  52.         long st_mode;
  53.         };
  54.  
  55. #define S_ISREG(mode)   (!(mode&0x10))
  56.  
  57. extern int dirstat(const char *file_name, struct stat *buf);
  58.  
  59. #endif /* macdir.h  */
  60.