home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckodir.h < prev    next >
C/C++ Source or Header  |  2020-01-01  |  2KB  |  75 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. #ifdef NT
  14. typedef unsigned short ino_t ;
  15. #endif
  16.  
  17.  
  18. #define MAXNAMLEN  256
  19. #ifndef MAXPATHLEN
  20. #define MAXPATHLEN 256
  21. #endif /* MAXPATHLEN */
  22.  
  23. #define A_RONLY    0x01
  24. #define A_HIDDEN   0x02
  25. #define A_SYSTEM   0x04
  26. #define A_LABEL    0x08
  27. #define A_DIR      0x10
  28. #define A_ARCHIVE  0x20
  29.  
  30. struct dirent
  31. {
  32.   ino_t    d_ino;                   /* a bit of a farce */
  33.   int      d_reclen;                /* more farce */
  34.   int      d_namlen;                /* length of d_name */
  35.   char     d_name[MAXNAMLEN + 1];   /* null terminated */
  36.   /* nonstandard fields */
  37.   long     d_size;                  /* size in bytes */
  38.   unsigned d_mode;                  /* DOS or OS/2 file attributes */
  39.   unsigned d_time;
  40.   unsigned d_date;
  41. };
  42.  
  43. /* The fields d_size and d_mode are extensions by me (Kai Uwe Rommel).
  44.  * The find_first and find_next calls deliver this data without any extra cost.
  45.  * If this data is needed, these fields save a lot of extra calls to stat()
  46.  * (each stat() again performs a find_first call !).
  47.  */
  48.  
  49. struct _dircontents
  50. {
  51.   char *_d_entry;
  52.          long _d_size;
  53.   unsigned int _d_mode, _d_time, _d_date;
  54.   struct _dircontents *_d_next;
  55. };
  56.  
  57. typedef struct _dirdesc
  58. {
  59.   int  dd_id;                   /* uniquely identify each open directory */
  60.   long dd_loc;                  /* where we are in directory entry is this */
  61.   struct _dircontents *dd_contents;   /* pointer to contents of dir */
  62.   struct _dircontents *dd_cp;         /* pointer to current position */
  63. }
  64. DIR;
  65.  
  66.  
  67. extern int attributes;
  68.  
  69. extern DIR *opendir(char *);
  70. extern struct dirent *readdir(DIR *);
  71. extern void seekdir(DIR *, long);
  72. extern long telldir(DIR *);
  73. extern void closedir(DIR *);
  74. #define rewinddir(dirp) seekdir(dirp, 0L)
  75.