home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / clustfre.c < prev    next >
C/C++ Source or Header  |  1993-10-14  |  2KB  |  88 lines

  1. /*
  2.  * File......: CLUSTFRE.C
  3.  * Author....: Dave Pearson
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Dave Pearson
  7.  * Date......: $Date$
  8.  * Revision..: $Revision$
  9.  * Log file..: $Logfile$
  10.  *
  11.  * This is an original work by Dave Pearson and is placed in the public
  12.  * domain.
  13.  *
  14.  * Modification history:
  15.  * ---------------------
  16.  *
  17.  * $Log$
  18.  *
  19.  */
  20.  
  21. // NOTE: This code has been written for and compiled with Borland C++
  22. //       Version 3.1
  23. //
  24.  
  25. #include <extend.h>
  26. #include "internal.h"
  27.  
  28. /*  $DOC$
  29.  *  $FUNCNAME$
  30.  *      GT_CLUSFRE()
  31.  *  $CATEGORY$
  32.  *      Disk Drive
  33.  *  $ONELINER$
  34.  *      Get the number of free clusters on a drive.
  35.  *  $SYNTAX$
  36.  *      GT_ClusFre([<ncDrive>]) --> nClusters
  37.  *  $ARGUMENTS$
  38.  *      <ncDrive> is an optional parameter that is the id of the drive
  39.  *      to be read. This paramater can be either a character value who's
  40.  *      first character is taken as the drive letter or a numeric value
  41.  *      where 0 = Default, 1 = A:, 2 = B:, etc... If no parameter is
  42.  *      passed the default drive is used.
  43.  *  $RETURNS$
  44.  *      The numer of free clusters on the drive. If the drive is invalid
  45.  *      the return value will be -1.
  46.  *  $DESCRIPTION$
  47.  *      GT_ClusFre() can be used to find the number of free clusters on
  48.  *      a disk.
  49.  *  $EXAMPLES$
  50.  *      // Each of the following print the number of free clusters found
  51.  *      // on drive C:
  52.  *
  53.  *      ? GT_ClusFre("C:")
  54.  *      ? GT_ClusFre("C")
  55.  *      ? GT_ClusFre("Clipper")         // First letter is used only.
  56.  *      ? GT_ClusFre(3)
  57.  *
  58.  *      // The next two print the number of free clusters in the current
  59.  *      // drive.
  60.  *
  61.  *      ? GT_ClusFre(0)
  62.  *      ? GT_ClusFre()
  63.  *  $SEEALSO$
  64.  *      GT_SECTSIZ() GT_CLUSTER() GT_SECPCLU()
  65.  *  $END$
  66.  */
  67.  
  68. CLIPPER GT_ClusFre()
  69. {
  70.         char Drive = _GT_Internal_GetDriveName(1);
  71.         unsigned Result;
  72.         unsigned Error;
  73.  
  74.         asm     Mov     AH,0x36
  75.         asm     Mov     DL,Drive
  76.         asm     Int     0x21
  77.         asm     Mov     Result,BX;
  78.         asm     Mov     Error,AX;
  79.         if (Error == 0xFFFF)
  80.         {
  81.                 _retnl(-1);
  82.         }
  83.         else
  84.         {
  85.                 _retnl(Result);
  86.         }
  87. }
  88.