home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6574.LZX / include / sys / dir.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-04  |  1.4 KB  |  54 lines

  1. /* Copyright (c) 1992 SAS Institute, Inc., Cary, NC USA */
  2. /* All Rights Reserved */
  3.  
  4. #ifndef _SYS_DIR_H
  5. #define _SYS_DIR_H
  6.  
  7. #include <sys/commargs.h>
  8.  
  9. #include <sys/types.h>
  10. #include <stat.h>
  11.  
  12. #define    DEV_BSIZE    1024
  13. #define  DIRBLKSIZ    DEV_BSIZE
  14. #define    MAXNAMLEN    255
  15.  
  16. struct    dirent {
  17.     u_long    d_ino;            /* inode number of entry */
  18.     u_short    d_reclen;        /* length of this record */
  19.     u_short    d_namlen;        /* length of string in d_name */
  20.     off_t       d_off;            /* offset of disk directory entry */
  21.     char       d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  22. };
  23.  
  24. /*
  25.  * The DIRSIZ macro gives the minimum record length which will hold
  26.  * the directory entry.  This requires the amount of space in struct direct
  27.  * without the d_name field, plus enough space for the name with a terminating
  28.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  29.  */
  30. #undef DIRSIZ
  31. #define DIRSIZ(dp) \
  32.     ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  33.  
  34. /*
  35.  * Definitions for library routines operating on directories.
  36.  */
  37. typedef struct _dirdesc {
  38.     long    dd_fd;
  39.     long    dd_loc;
  40.     long    dd_size;
  41.     char    *dd_buf;
  42. } DIR;
  43.  
  44. #include <sys/commnull.h>
  45.  
  46. extern    DIR           *opendir __ARGS((const char *));
  47. extern    struct dirent *readdir __ARGS((DIR *));
  48. extern    long          telldir  __ARGS((DIR *));
  49. extern    void          seekdir  __ARGS((DIR *, long));
  50. extern    void          closedir __ARGS((DIR *));
  51. #define rewinddir(dirp)    seekdir((dirp), (long)0)
  52.  
  53. #endif
  54.