xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_DiskSpace()

Returns the free storage space for a disk drive by drive letter.

Syntax

HB_DiskSpace( <cDrive>, [<nType>] ) --> nBytes

Arguments

<cDrive>
A single character from A to Z specifies the disk drive to query.
<nType>
Optionally, the type of storage space on a drive to query can be specified using #define constants from the FILEIO.CH file. Valid constants are listed below:

Storage space types for HB_DiskSpace()
ConstantValueDescription
HB_DISK_AVAIL *)0Free disk space avialable to the application
HB_DISK_FREE1Total free disk space
HB_DISK_USED2Used disk space
HB_DISK_TOTAL3Total disk space

Return

The function returns a numeric value indicating the storage space of a disk drive. If no parameters are passed, DiskSpace() returns the free disk space on the current drive that is available to the application.

Description

HB_DiskSpace() determines free and used bytes on a disk drive accepting a drive letter. Some operating systems distinguish between total free bytes on disk and free bytes that are avalaible to the current user, or application. If the current operating system makes no such distinction, HB_DISK_AVAIL and HB_DISK_FREE yield the same results.

Note:  if information is requested on a disk that is not available, a runtime error 2018 is generated.

Info

See also:Directory(), DiskName(), DiskSpace(), File(), FOpen(), FSeek(), IsDisk()
Category: Disks and Drives , xHarbour extensions
Source:rtl\disksphb.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example lists two disk storage types for all drives taking
// advantage of the runtime error created for unaccessible drives.

   #include "Fileio.ch"

   PROCEDURE Main
      LOCAL cDrive, i, bError := ErrorBlock( {|e| Break(e) } )

      FOR i:=1 TO 26
         cDrive := Chr(64+i)
         ? cDrive+":"
         BEGIN SEQUENCE
           ?? HB_DiskSpace( cDrive, HB_DISK_FREE ), ;
              HB_DiskSpace( cDrive, HB_DISK_TOTAL)
         RECOVER
           ?? " not ready or not existent"
         END SEQUENCE
      NEXT

      ErrorBlock( bError )
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe