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