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