home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntinc25.zoo / dirent.h < prev    next >
C/C++ Source or Header  |  1992-12-07  |  3KB  |  100 lines

  1. /* header file for POSIX directory access routines */
  2.  
  3. #ifndef _DIRENT_H
  4. #define _DIRENT_H
  5.  
  6. #ifndef _COMPILER_H
  7. #include <compiler.h>
  8. #endif
  9.  
  10. #ifndef _TYPES_H
  11. #include <types.h>
  12. #endif
  13.  
  14. #ifndef NAME_MAX
  15. # include <limits.h>
  16. #endif
  17.  
  18. #ifdef __MINT__
  19. # ifndef _OSTRUCT_H
  20. #  include <ostruct.h>
  21. # endif
  22. #endif
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28.  
  29. #ifndef _LIB_NAME_MAX
  30. #  define _LIB_NAME_MAX NAME_MAX
  31. #endif
  32.  
  33. struct dirent {
  34.        long            d_ino;          /* garbage under TOS */
  35.        off_t           d_off;          /* position in directory  */
  36.        short           d_reclen;       /* for us, length of d_name */
  37. #ifndef __MINT__
  38. /* the following (except for d_name) are unique to TOS */
  39.        struct dirent   *d_next;        /* ptr to next struct dirent in list */
  40.        unsigned char   d_attribute;    /* file modes from Fsfirst()  */
  41.        unsigned short  d_time, d_date; /* TOS date and time for file */
  42.        long            d_size;         /* file size */
  43.        char            d_name[1];
  44. #else
  45.        char            d_name[NAME_MAX+1];
  46. #endif
  47. };
  48.  
  49. #ifndef __MINT__
  50. typedef struct _DIR {
  51.        struct dirent *D_list;          /* list of directory entries */
  52.        struct dirent *D_curpos;        /* current position in list  */
  53.        char          *D_path;          /* path to this directory    */
  54.        struct _DIR   *D_nxtdir;        /* next DIR in opendir chain */
  55. } DIR;
  56.  
  57. #else
  58.  
  59. typedef struct _DIR {
  60.     short    status;        /* status of the search so far: */
  61. #define _INSEARCH    0    /* need to call Fsnext for a new entry */
  62. #define _STARTSEARCH    1    /* Fsfirst called once, successfully */
  63. #define _NMFILE        2    /* no more files in directory */
  64.     _DTA    dta;        /* TOS DTA for this directory */
  65.     char    *dirname;    /* directory of the search (used under
  66.                    TOS for rewinddir) */
  67.     struct dirent buf;    /* dirent struct for this directory */
  68.     long    handle;        /* Dreaddir handle */
  69. } DIR;
  70.  
  71. #endif /* __MINT__ */
  72.  
  73.  
  74. #define DIRENTSIZ(x) (sizeof(struct dirent) + (x) + 1)
  75.  
  76. /* allow BSD emulation via sys/dir.h */
  77.  
  78. #ifdef _SYS_DIR_H
  79. #define direct        dirent
  80. #define d_fileno    d_ino
  81. #define d_namlen    d_reclen
  82.  
  83. #define DIRSIZ(dp)     DIRENTSIZ((dp)->d_namlen)
  84. #define MAXNAMLEN    _LIB_NAME_MAX
  85. #endif
  86.  
  87.  
  88. __EXTERN DIR *        opendir    __PROTO((const char *dirname));
  89. __EXTERN struct dirent *readdir    __PROTO((DIR *dirp));
  90. __EXTERN off_t        telldir __PROTO((DIR *dirp));
  91. __EXTERN void        seekdir    __PROTO((DIR *dirp, off_t loc));
  92. __EXTERN void        rewinddir __PROTO((DIR *dirp));
  93. __EXTERN int        closedir  __PROTO((DIR *dirp));
  94.  
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98.  
  99. #endif /* _DIRENT_H */
  100.