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

  1. /*
  2.  * File......: SECTSIZE.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_SECTSIZ()
  31.  *  $CATEGORY$
  32.  *      Disk Drive
  33.  *  $ONELINER$
  34.  *      Get the size of a sector on a drive.
  35.  *  $SYNTAX$
  36.  *      GT_SectSiz([<ncDrive>]) --> nSectorSize
  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 size of a sector on the drive in bytes. If the drive is
  45.  *      invalid the return value will be -1.
  46.  *  $DESCRIPTION$
  47.  *      GT_SectSiz() can be used to find the size in bytes of a sector
  48.  *      on a disk.
  49.  *  $EXAMPLES$
  50.  *      // Each of the following print the size of a sector on drive C:
  51.  *
  52.  *      ? GT_SectSiz("C:")
  53.  *      ? GT_SectSiz("C")
  54.  *      ? GT_SectSiz("Clipper")         // First letter is used only.
  55.  *      ? GT_SectSiz(3)
  56.  *
  57.  *      // The next two print the size of a sector on the current drive.
  58.  *
  59.  *      ? GT_SectSiz(0)
  60.  *      ? GT_SectSiz()
  61.  *  $SEEALSO$
  62.  *      GT_CLUSTER() GT_CLUSFRE() GT_SECPCLU()
  63.  *  $END$
  64.  */
  65.  
  66. CLIPPER GT_SectSiz()
  67. {
  68.         char Drive = _GT_Internal_GetDriveName(1);
  69.         unsigned Result;
  70.         unsigned Error;
  71.  
  72.         asm     Mov     AH,0x36
  73.         asm     Mov     DL,Drive
  74.         asm     Int     0x21
  75.         asm     Mov     Result,CX;
  76.         asm     Mov     Error,AX;
  77.         if (Error == 0xFFFF)
  78.         {
  79.                 _retnl(-1);
  80.         }
  81.         else
  82.         {
  83.                 _retnl(Result);
  84.         }
  85. }
  86.