xHarbour Reference Documentation > Function Reference |
Returns the free storage space for a disk drive.
DiskSpace( [<nDrive>], [<nType>] ) --> nBytes
Storage space types for DiskSpace()
Constant | Value | Description |
---|---|---|
HB_DISK_AVAIL *) | 0 | Free disk space avialable to the application |
HB_DISK_FREE | 1 | Total free disk space |
HB_DISK_USED | 2 | Used disk space |
HB_DISK_TOTAL | 3 | Total disk space |
*) default |
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.
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.
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 |
// 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
http://www.xHarbour.com