home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckc190.zip / ckodir.h < prev    next >
C/C++ Source or Header  |  1994-06-01  |  2KB  |  72 lines

  1. /*
  2.  * @(#) dir.h 1.4 87/11/06   Public Domain.
  3.  *
  4.  *  A public domain implementation of BSD directory routines for
  5.  *  MS-DOS.  Written by Michael Rendell ({uunet,utai}michael@garfield),
  6.  *  August 1987
  7.  *
  8.  *  Enhanced and ported to OS/2 by Kai Uwe Rommel
  9.  *  December 1989, February 1990
  10.  *  Change of MAXPATHLEN for HPFS, October 1990
  11.  */
  12.  
  13.  
  14. #define MAXNAMLEN  256
  15. #ifndef MAXPATHLEN
  16. #define MAXPATHLEN 256
  17. #endif /* MAXPATHLEN */
  18.  
  19. #define A_RONLY    0x01
  20. #define A_HIDDEN   0x02
  21. #define A_SYSTEM   0x04
  22. #define A_LABEL    0x08
  23. #define A_DIR      0x10
  24. #define A_ARCHIVE  0x20
  25.  
  26.  
  27. struct dirent
  28. {
  29.   ino_t    d_ino;                   /* a bit of a farce */
  30.   int      d_reclen;                /* more farce */
  31.   int      d_namlen;                /* length of d_name */
  32.   char     d_name[MAXNAMLEN + 1];   /* null terminated */
  33.   /* nonstandard fields */
  34.   long     d_size;                  /* size in bytes */
  35.   unsigned d_mode;                  /* DOS or OS/2 file attributes */
  36.   unsigned d_time;
  37.   unsigned d_date;
  38. };
  39.  
  40. /* The fields d_size and d_mode are extensions by me (Kai Uwe Rommel).
  41.  * The find_first and find_next calls deliver this data without any extra cost.
  42.  * If this data is needed, these fields save a lot of extra calls to stat()
  43.  * (each stat() again performs a find_first call !).
  44.  */
  45.  
  46. struct _dircontents
  47. {
  48.   char *_d_entry;
  49.   long _d_size;
  50.   unsigned _d_mode, _d_time, _d_date;
  51.   struct _dircontents *_d_next;
  52. };
  53.  
  54. typedef struct _dirdesc
  55. {
  56.   int  dd_id;                   /* uniquely identify each open directory */
  57.   long dd_loc;                  /* where we are in directory entry is this */
  58.   struct _dircontents *dd_contents;   /* pointer to contents of dir */
  59.   struct _dircontents *dd_cp;         /* pointer to current position */
  60. }
  61. DIR;
  62.  
  63.  
  64. extern int attributes;
  65.  
  66. extern DIR *opendir(char *);
  67. extern struct dirent *readdir(DIR *);
  68. extern void seekdir(DIR *, long);
  69. extern long telldir(DIR *);
  70. extern void closedir(DIR *);
  71. #define rewinddir(dirp) seekdir(dirp, 0L)
  72.