home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / DISKFUNC.PRG < prev    next >
Text File  |  1991-08-16  |  3KB  |  120 lines

  1. /*
  2.  * File......: DISKFUNC.PRG
  3.  * Author....: Robert A. DiFalco
  4.  * Date......: $Date:   15 Aug 1991 23:02:20  $
  5.  * Revision..: $Revision:   1.2  $
  6.  * Log file..: $Logfile:   E:/nanfor/src/diskfunc.prv  $
  7.  * 
  8.  * This is an original work by Robert A. DiFalco and is placed in
  9.  * the public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   E:/nanfor/src/diskfunc.prv  $
  15.  * 
  16.  *    Rev 1.2   15 Aug 1991 23:02:20   GLENN
  17.  * Forest Belt proofread/edited/cleaned up doc
  18.  * 
  19.  *    Rev 1.1   14 Jun 1991 17:49:28   GLENN
  20.  * Documentation format change (minor).
  21.  * Added work around suggested by a number of Nanforum users; sometimes 
  22.  * _ftDiskFunc() would return negative numbers on large drives.
  23.  * 
  24.  *    Rev 1.0   01 Apr 1991 01:01:12   GLENN
  25.  * Nanforum Toolkit
  26.  *
  27.  */
  28.  
  29. #include "FTINT86.CH"
  30.  
  31. #define DRVTABLE "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  32.  
  33. #ifdef FT_TEST
  34.   FUNCTION MAIN( cDrv )
  35.  
  36.      QOut("Disk size:   " + str( FT_DSKSIZE() ) )
  37.      QOut("Free bytes:  " + str( FT_DSKFREE() ) )
  38.  
  39.   return ( nil )
  40. #endif
  41.  
  42. /*  $DOC$
  43.  *  $FUNCNAME$
  44.  *     FT_DSKSIZE()
  45.  *  $CATEGORY$
  46.  *     DOS/BIOS
  47.  *  $ONELINER$
  48.  *     Return the maximum capacity of a fixed disk
  49.  *  $SYNTAX$
  50.  *     FT_DSKSIZE( [ <cDrive> ] ) -> nMaxCapacity
  51.  *  $ARGUMENTS$
  52.  *     <cDrive> is the fixed disk to query. If no drive is sent, the
  53.  *     operation will be performed on the default drive. Send without
  54.  *     the ":".
  55.  *  $RETURNS$
  56.  *     An integer representing the maximum disk capacity in bytes.
  57.  *  $DESCRIPTION$
  58.  *     Function utilizing FT_INT86() to return Maximum Disk Size.
  59.  *     Uses FT_INT86() through the internal function _ftDiskInfo().
  60.  *  $EXAMPLES$
  61.  *     ? FT_DSKSIZE()      // Maximum capacity for default drive
  62.  *     ? FT_DSKSIZE( "D" ) // Maximum capacity for Drive D:
  63.  *  $END$
  64.  */
  65.  
  66. FUNCTION FT_DSKSIZE( cDrive )
  67.    local aReg[INT86_MAX_REGS]
  68.  
  69.    _ftDiskInfo( cDrive, aReg )
  70.    aReg[4] := if(aReg[4] >= 0,aReg[4],65536+aReg[4])  //work around
  71.  
  72. RETURN iif( aReg[1] == -1, aReg[1], aReg[1] * aReg[3] * aReg[4] )
  73.  
  74.  
  75.  
  76. /*  $DOC$
  77.  *  $FUNCNAME$
  78.  *     FT_DSKFREE()
  79.  *  $CATEGORY$
  80.  *     DOS/BIOS
  81.  *  $ONELINER$
  82.  *     Return the amount of available disk space
  83.  *  $SYNTAX$
  84.  *     FT_DSKFREE( [ <cDrive> ] ) -> nSpaceAvail
  85.  *  $ARGUMENTS$
  86.  *     <cDrive> is the fixed disk to query. If no parameter is passed
  87.  *     the operation will be performed on the default drive.  Do not
  88.  *     include the ":".
  89.  *  $RETURNS$
  90.  *     Integer representing the available disk space in bytes.
  91.  *  $DESCRIPTION$
  92.  *     Function to return the available space on the passed
  93.  *     drive letter or the default drive if no drive is passed.
  94.  *
  95.  *     Uses FT_INT86() through the internal function _ftDiskInfo().
  96.  *  $EXAMPLES$
  97.  *     ? FT_DSKFREE()  // Returns free space on default drive.
  98.  *  $END$
  99.  */
  100.  
  101.  
  102. FUNCTION FT_DSKFREE( cDrive )
  103.    local aReg[INT86_MAX_REGS]
  104.  
  105.    _ftDiskInfo( cDrive, aReg )
  106.    aReg[2] := if(aReg[2] >= 0,aReg[2],65536+aReg[2]) // work around
  107.  
  108. RETURN iif( aReg[1] == -1, aReg[1], aReg[1] * aReg[3] * aReg[2] )
  109.  
  110. STATIC FUNCTION _ftDiskInfo( cDrive, aReg )
  111.    local nDrive
  112.  
  113.    nDrive := if( cDrive == NIL, 0, at( upper(cDrive), DRVTABLE ) )
  114.  
  115.    aReg[1] := MAKEHI( 54 )
  116.    aReg[4] := nDrive
  117.    FT_INT86( 33, aReg )
  118.  
  119. RETURN Nil
  120.