home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs57pc3.zip / diff / pc / dirent.h < prev    next >
C/C++ Source or Header  |  1999-01-03  |  3KB  |  91 lines

  1. /* @(#) dirent.h
  2.  * public domain implementation of POSIX directory routines 
  3.  * for DOS, OS/2 and Win32
  4.  */
  5.  
  6. #if HAVE_LIMITS_H
  7. #include <limits.h>
  8. #endif
  9.  
  10. #ifndef _POSIX_NAME_MAX
  11. #define _POSIX_NAME_MAX  256
  12. #endif
  13. #ifndef _POSIX_PATH_MAX
  14. #define _POSIX_PATH_MAX  260
  15. #endif
  16.  
  17. struct dirent
  18. {
  19.   ino_t    d_ino;                         /* a bit of a farce */
  20.   int      d_reclen;                      /* more farce */
  21.   int      d_namlen;                      /* length of d_name */
  22.   char     d_name[_POSIX_NAME_MAX + 1];   /* null terminated */
  23.   /* nonstandard fields */
  24.   long     d_size;                        /* size in bytes */
  25.   unsigned d_mode;                        /* file attributes */
  26.   unsigned d_time;                        /* file time */
  27.   unsigned d_date;                        /* file date */
  28. };
  29.  
  30. /* The fields d_size, d_mode, d_time and d_date are extensions.
  31.  * The find_first and find_next calls deliver this data without
  32.  * any extra cost. If this data is needed, these fields save a lot
  33.  * of extra calls to stat() (each stat() again does a find_first!).
  34.  */
  35.  
  36. struct d_dircontents
  37. {
  38.   char *d_dc_entry;
  39.   long  d_dc_size;
  40.   unsigned d_dc_mode;
  41.   unsigned d_dc_time;
  42.   unsigned d_dc_date;
  43.   struct d_dircontents *d_dc_next;
  44. };
  45.  
  46. struct d_dirdesc
  47. {
  48.   int   d_dd_id;           /* uniquely identify each open directory */
  49.   long  d_dd_loc;          /* where we are in directory entry is this */
  50.   struct d_dircontents *d_dd_contents; /* pointer to contents of dir */
  51.   struct d_dircontents *d_dd_cp;       /* pointer to current position */
  52.   char d_dd_name[_POSIX_PATH_MAX];     /* remember name for rewinddir */
  53. };
  54.  
  55. typedef struct d_dirdesc DIR;
  56.  
  57.  
  58. extern DIR *opendir(const char *);
  59. extern struct dirent *readdir(DIR *);
  60. extern void rewinddir(DIR *);
  61. extern int closedir(DIR *);
  62.  
  63. #ifndef _POSIX_SOURCE
  64.  
  65. extern void seekdir(DIR *, long);
  66. extern long telldir(DIR *);
  67.  
  68. #ifndef _A_NORMAL
  69. #define _A_NORMAL   0x00
  70. #define _A_RONLY    0x01
  71. #define _A_HIDDEN   0x02
  72. #define _A_SYSTEM   0x04
  73. #define _A_LABEL    0x08
  74. #define _A_DIR      0x10
  75. #define _A_ARCHIVE  0x20
  76. #endif
  77.  
  78. extern int attributes;
  79.  
  80. extern int scandir(char *, struct dirent ***,
  81.                    int (*)(struct dirent *),
  82.                    int (*)(struct dirent *, struct dirent *));
  83.  
  84. extern int getfmode(char *);
  85. extern int setfmode(char *, unsigned);
  86.  
  87. extern int IsFileNameValid(char *name);
  88. extern int IsFileSystemDumb(char *dir);
  89.  
  90. #endif
  91.