home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / SHFRAG.ZIP / DISK_API.H < prev    next >
C/C++ Source or Header  |  1992-02-06  |  4KB  |  138 lines

  1. //
  2. //  Disk_Api.h
  3. //
  4. //  Please define either __DOS__ or __OS2__
  5. //
  6.  
  7. // ######################### DOS ####################################
  8. #ifdef __DOS__
  9.  
  10. #include <dos.h>
  11.  
  12. #ifndef USHORT
  13. #define USHORT unsigned short
  14. #endif
  15.  
  16. #ifndef BYTE
  17. #define BYTE unsigned char
  18. #endif
  19.  
  20. #ifndef TRUE
  21. #define FALSE 0
  22. #define TRUE !FALSE
  23. #endif
  24.  
  25. #define FILES (_A_SYSTEM | _A_HIDDEN | _A_SUBDIR)
  26. #define DIRECTORY _A_SUBDIR
  27.  
  28. #define USHORT unsigned short     // unsigned integer type
  29. #define ULONG  unsigned long      // unsigned long type
  30.  
  31. typedef struct            // Disk transfer area layout
  32. {
  33.     char   dta1[6];       //  06 first part of dta
  34.     char   x_attribute;   //  01 attribute byte
  35.     char   drive;         //  01 drive
  36.     char   name[8];       //  08 filename
  37.     char   ext[3];        //  03 extension
  38.     char   attribute;     //  01 directory attribute
  39.     char   dta2[10];      //  10 more reserved space
  40.     short  time;          //  02 directory time
  41.     short  date;          //  02 directory date
  42.     short  cluster;       //  02 first cluster
  43.     long   size;          //  04 size of file
  44.     char   filler[128-40];//  88
  45.                           // 128 <= total structure
  46. } Dta;
  47.  
  48. typedef struct fcb
  49. {
  50.     char    hexff;       // extended fcb first byte
  51.     char    extra[5];    // extended fcb work area
  52.     char    attribute;   // extended fcb attribute
  53.     char    drive;       // fcb - drive
  54.     char    name[8];     // fcb - filename
  55.     char    ext[3];      // fcb - extension
  56.     USHORT  block;       // fcb - block number
  57.     ULONG   size;        // fcb - file size
  58.     int     date;        // fcb - file date
  59.     char    system[10];  // fcb - reserved area
  60.     char    record;      // fcb - current record
  61.     ULONG   rnd_recno;   // fcb - random record number
  62. } Fcb;
  63.  
  64. typedef struct
  65. {
  66.   // Private section.
  67.   short   oldds, oldda;
  68.   Fcb     fcb;
  69.   Dta     dta;
  70.  
  71.   // Public  section.
  72.   USHORT  attrib;
  73.   USHORT  cluster;
  74.   ULONG   size;
  75.   char    name[13];
  76. } Directory;
  77. #endif
  78.  
  79. // ######################### OS2 ####################################
  80. #ifdef __OS2__
  81. #define INCL_DOS
  82. #define INCL_DOSDEVIOCTL
  83. #define INCL_NOPM
  84. #include <os2.h>
  85.  
  86. #define FILES (FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY)
  87. #define DIRECTORY FILE_DIRECTORY
  88.  
  89. typedef struct
  90. {
  91.   char  name[8];             // 08
  92.   char  ext[3];              // 03
  93.   UCHAR attribute;           // 01
  94.   short reserved[5];         // 10
  95.   short time;                // 02
  96.   short date;                // 02
  97.   short cluster;             // 02
  98.   long  size;                // 04
  99. } Disk_dir_entry;            // 32
  100.  
  101. typedef struct
  102. {
  103.   // Private section.
  104.   Disk_dir_entry entries[16];
  105.   short       entry;
  106.   ULONG       sector;
  107.   long        n_sectors;
  108.   USHORT      fat_entry;
  109.   USHORT      next_fat_entry;
  110.   USHORT      search_attributes;
  111.  
  112.   // Public  section.
  113.   USHORT      attrib;
  114.   USHORT      cluster;
  115.   ULONG       size;
  116.   char        name[13];
  117. } Directory;
  118. #endif
  119.  
  120. // ######################### Common Prototypes #######################
  121.  
  122. extern void       DosSetDrive(char drive_letter);
  123. extern char      *translate_name(char *name);
  124. extern short      DosDiskValid(char drive_letter);
  125. extern USHORT     DosOpenDrive(char drive_letter);
  126. extern void       DosCloseDrive(USHORT handle);
  127. extern USHORT     DosBytesPerDiskSector(USHORT drive_handle);
  128. extern short      DosReadSector(USHORT handle, void far* buffer, ULONG sector,
  129.                   USHORT count);
  130. extern void       DosDirInitialize(USHORT handle, USHORT huge *fat, ULONG fat_size,
  131.                   USHORT SectorsPerCluster, USHORT BytesPerSector,
  132.                   USHORT RootSector, USHORT FirstFileSector);
  133. extern Directory *DosDirClose(Directory *dir);
  134. extern Directory *DosDirFindFirst(char* find, USHORT attributes,
  135.                   USHORT DirCluster);
  136. extern Directory *DosDirFindNext(Directory *dir);
  137. extern char*      DosDiskVolume(char drive_letter, char* vol, short size);
  138.