home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / SNIP9404.ZIP / DIRENT.H < prev    next >
C/C++ Source or Header  |  1994-04-03  |  3KB  |  98 lines

  1. /*
  2. **  DIRENT.H - Posix compliant header
  3. **
  4. **  Original Copyright 1988-1991 by Bob Stout as part of
  5. **  the MicroFirm Function Library (MFL)
  6. **
  7. **  This subset version is functionally identical to the
  8. **  version originally published by the author in Tech Specialist
  9. **  magazine and is hereby donated to the public domain.
  10. */
  11.  
  12. #ifndef DIRENT_H
  13. #define DIRENT_H
  14.  
  15. #include <stdio.h>                        /* For FILENAME_MAX     */
  16. #include <dos.h>
  17.  
  18. #ifndef OS2
  19.  #if defined(__ZTC__)
  20.   #define DSTRUCT       FIND              /* ZTC++/SC++           */
  21.   #define ATTRIBUTE     attribute
  22.   #define NAME          name
  23.   #define TIME          time
  24.   #define DATE          date
  25.   #define FSIZE         size
  26.   #pragma pack(1)
  27.   #include <direct.h>
  28.  #elif defined(__TURBOC__)
  29.   #define DSTRUCT       ffblk             /* TC/C++               */
  30.   #define ATTRIBUTE     ff_attrib
  31.   #define NAME          ff_name
  32.   #define TIME          ff_ftime
  33.   #define DATE          ff_fdate
  34.   #define FSIZE         ff_fsize
  35.   #include <dir.h>
  36.  #else
  37.   #define DSTRUCT       find_t            /* Assume MSC/QC        */
  38.   #define ATTRIBUTE     attrib
  39.   #define NAME          name
  40.   #define TIME          time
  41.   #define DATE          date
  42.   #define FSIZE         size
  43.   #pragma pack(1)
  44.   #include <direct.h>
  45.  #endif
  46. #else                                     /* OS/2                 */
  47.  #define INCL_DOSFILEMAN
  48.  #include <os2.h>
  49.  struct DSTRUCT {
  50.        BYTE  reserved[21];
  51.        BYTE  ATTRIBUTE;
  52.        FTIME TIME;
  53.        FDATE DATE;
  54.        ULONG FSIZE;
  55.        CHAR  NAME[13];
  56.  };
  57. #endif
  58.  
  59. #define FA_ANY 0xff
  60. #undef FA_DIREC
  61. #define FA_DIREC 0x10
  62.  
  63. /*
  64. **  Portable find first/next functions from RFIND1ST.C
  65. */
  66.  
  67. struct DSTRUCT *rfind_1st(char *, unsigned, struct DSTRUCT *);
  68. struct DSTRUCT *rfind_nxt(struct DSTRUCT *);
  69.  
  70. typedef struct
  71. {
  72.       int               dd_fd;
  73.       unsigned          dd_loc,
  74.                         dd_size;
  75.       struct DSTRUCT    dd_buf;
  76.       char              dd_dirname[FILENAME_MAX];
  77. } DOS_DIR;
  78.  
  79. DOS_DIR        *opendir(char *);
  80. int             closedir(DOS_DIR *),
  81.                 rewinddir(DOS_DIR *);
  82. struct DSTRUCT *readdir(DOS_DIR *),
  83.                *seekdir(DOS_DIR *, int, int);
  84. #define         telldir(dd) dd->loc
  85.  
  86. /*
  87. **  Other useful functions from DIRMASK.C and PATMAT.C
  88. */
  89.  
  90. int             dirmask(struct DSTRUCT *,char *,char *,unsigned,unsigned);
  91. int             patmat(const char *, const char *);
  92.  
  93. extern int DFerr;
  94.  
  95. extern DOS_DIR _DIRS[];
  96.  
  97. #endif /* DIRENT_H */
  98.