xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DiskSpace()

Returns the free storage space for a disk drive.

Syntax

DiskSpace( [<nDrive>], [<nType>] ) --> nBytes

Arguments

<nDrive>
The drive to query for free disk space is specified as a numeric value in the range of 1 (drive A:) to 26 (drive Z:). Omitting <nDrive> or passing 0 returns the disk space avalable on the current drive.
<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 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

DiskSpace() determines free and used bytes on a disk drive. 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(), File(), FOpen(), FSeek(), HB_DiskSpace(), IsDisk(), LastRec(), LUpdate(), RecCount(), RecSize()
Category: Disks and Drives , File functions
Header:fileio.ch
Source:rtl\diskspac.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 i, bError := ErrorBlock( {|e| Break(e) } )

      FOR i:=1 TO 26
         BEGIN SEQUENCE
           ? "Drive",Chr(64+i)+":", DiskSpace( i, HB_DISK_FREE ), ;
                                    DiskSpace( i, HB_DISK_TOTAL)
         RECOVER
           ?"Drive",Chr(64+i)+":", "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