home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 5.ddi / CLIBSRC2.ZIP / GETFAT.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  3.9 KB  |  129 lines

  1. /*---------------------------------------------------------------------------
  2.  * filename - getfat.cas
  3.  *
  4.  * function(s)
  5.  *        getfatd  - gets file-allocation table information
  6.  *        getfat   - gets file-allocation table information
  7.  *        getdfree - gets disk free space
  8.  *--------------------------------------------------------------------------*/
  9.  
  10. /*
  11.  *      C/C++ Run Time Library - Version 5.0
  12.  *
  13.  *      Copyright (c) 1987, 1992 by Borland International
  14.  *      All Rights Reserved.
  15.  *
  16.  */
  17.  
  18.  
  19. #pragma inline
  20. #include <dos.h>
  21. #include <dir.h>
  22.  
  23. /*--------------------------------------------------------------------------*
  24.  
  25. Name            getfatd - gets file-allocation table information
  26.  
  27. Usage           #include <dos.h>
  28.                 void getfatd(struct fatinfo *fatblkp);
  29.  
  30. Prototype in    dos.h
  31.  
  32. Description     see getfat
  33.  
  34. *---------------------------------------------------------------------------*/
  35. void getfatd(struct fatinfo *dtable)
  36. {
  37.         getfat(0, dtable);
  38. }
  39.  
  40.  
  41. /*--------------------------------------------------------------------------*
  42.  
  43. Name            getfat - gets file-allocation table information
  44.  
  45. Usage           #include <dos.h>
  46.                 void getfat(unsigned char drive, struct fatinfo *fatblkp);
  47.  
  48. Related
  49. functions usage void getfatd(struct fatinfo *fatblkp);
  50.  
  51. Prototype in    dos.h
  52.  
  53. Description     getfat returns information from the file-allocation
  54.                 table for the drive specified by drive (0 = default, 1 = A:,
  55.                 2 = B:, etc.). fatblkp points to the fatinfo
  56.                 structure to be filled in.
  57.  
  58.                 getfatd performs the same function as getfat except that the
  59.                 default drive (0) is always used.
  60.  
  61.                 The fatinfo structure filled in by getfat and getfatd is
  62.                 defined as follows:
  63.  
  64.                 struct fatinfo {
  65.                         char fi_sclus;  (* Sectors per cluster *)
  66.                         char fi_fatid;  (* The FAT id byte *)
  67.                         int fi_nclus;   (* Number of clusters *)
  68.                         int fi_bysec;   (* Bytes per sector *)
  69.                 };
  70.  
  71. *---------------------------------------------------------------------------*/
  72. void getfat(unsigned char drive, struct fatinfo *dtable)
  73. {
  74. #if !defined(__HUGE__)
  75. asm     push    ds
  76. #endif
  77. asm     mov     ah, 01ch
  78. asm     mov     dl, drive
  79. asm     int     021h
  80. asm     mov     ah, [bx]
  81. #if !defined(__HUGE__)
  82. asm     pop     ds
  83. #endif
  84.         ((int *)dtable)[0] = _AX;
  85.         ((int *)dtable)[1] = _DX;
  86.         ((int *)dtable)[2] = _CX;
  87. }
  88.  
  89.  
  90. /*--------------------------------------------------------------------------*
  91.  
  92. Name            getdfree - gets disk free space
  93.  
  94. Usage           #include <dos.h>
  95.                 void getdfree(int drive, struct dfree *dfreep);
  96.  
  97. Prototype in    dos.h
  98.  
  99. Description     accepts a drive specifier in drive (0 = default, 1 = A, etc.)
  100.                 and fills in the dfree structure pointed to by dfreep with
  101.                 disk characteristics.
  102.  
  103.                 The dfree structure is defined as follows:
  104.  
  105.                 struct dfree {
  106.                         unsigned df_avail;      (* Available clusters *)
  107.                         unsigned df_total;      (* Total clusters *)
  108.                         unsigned df_bsec;       (* Bytes per sector *)
  109.                         unsigned df_sclus;      (* Sectors per cluster *)
  110.                 };
  111.  
  112. Return value    Nothing. In the event of an error, df_sclus in the
  113.                 dfree structure is set to -1.
  114.  
  115. *---------------------------------------------------------------------------*/
  116. void getdfree(unsigned char drive, struct dfree *dtable)
  117. {
  118.         int     i;
  119.  
  120. asm     mov     ah, 036h
  121. asm     mov     dl, drive
  122. asm     int     021h
  123.         i = _BX;
  124.         ((int *)dtable)[3] = _AX;
  125.         ((int *)dtable)[0] = i;
  126.         ((int *)dtable)[1] = _DX;
  127.         ((int *)dtable)[2] = _CX;
  128. }
  129.