home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_08 / 2n08073a < prev    next >
Text File  |  1991-07-01  |  2KB  |  74 lines

  1.  
  2.  
  3.  
  4.                Listing 3: Directory Functions
  5.  
  6.  
  7.      /*-----------------------------------------------------
  8.          Directory search macros and data structures
  9.      
  10.          DOSFileData  MS-DOS file data structure
  11.          FIND_FIRST   MS-DOS function 0x4E -- find first file
  12.          FIND_NEXT    MS-DOS function 0x4F -- find next file
  13.      -------------------------------------------------------
  14.      
  15.      /* make sure the struct is packed on byte boundary */
  16.      #if defined(_MSC_VER) || defined(_QC) ||
  17.      defined(__WATCOMC__)
  18.          #pragma pack(1)
  19.      #elif defined(__ZTC__)
  20.          #pragma align 1
  21.      #elif defined(__TURBOC__)
  22.          #pragma option -a-
  23.      #endif
  24.      
  25.      /* use this struct instead of compiler-defined file
  26.      struct */
  27.      typedef struct
  28.          {
  29.          char     reserved[21];
  30.          char     attrib;
  31.          unsigned time;
  32.          unsigned date;
  33.          long     size;
  34.          char     name[13];
  35.          }
  36.          DOSFileData;
  37.      
  38.      /* set structure alignment to default */
  39.      #if defined (_MSC_VER) || defined(_QC) ||
  40.      defined(__WATCOMC__)
  41.          #pragma pack()
  42.      #elif defined(__ZTC__)
  43.          #pragma align
  44.      #elif defined(__TURBOC__)
  45.          #pragma option -a.
  46.      #endif
  47.      
  48.      /* include proper header files and create macros */
  49.      #if defined(_MSC_VER) || defined(_QC) ||
  50.      defined(__WATCOMC__)
  51.          #include "direct.h"
  52.      
  53.          #define FIND_FIRST(spec, attr, buf) \
  54.                    _dos_findfirst(spec, attr, (struct find_t *)buf)
  55.          #define FIND_NEXT(buf) _dos_findnext((struct find_t
  56.      *)buf)
  57.      #elif defined(__TURBOC__)
  58.          #include "dir.h"
  59.      
  60.          #define FIND_FIRST(spec, attr, buf) \
  61.                     findfirst(spec, (struct ffblk *)buf, attr)
  62.          #define FIND_NEXT(buf) findnext((struct ffblk
  63.      *)buf)
  64.      #elif defined(__ZTC__)
  65.          #include "dos.h"
  66.      
  67.          #define FIND_FIRST(spec, attr, buf) \
  68.                     dos_findfirst(spec, attr, (struct DOS_FIND *)buf)
  69.          #define FIND_NEXT(buf) dos_findnext((struct
  70.      DOS_FIND *)buf)
  71.      #endif
  72.  
  73.  
  74.