| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Verify if a drive is ready
IsDisk( <cDrive> ) --> lDriveIsReady
The function returns .T. (true) if the disk drive <cDrive> is ready, otherwise .F. (false)
This function attempts to access a drive. If the access to the drive is successful, it returns .T. (true). The function is useful for backup routines that require to test if a disk drive is ready, before starting with the backup procedure.
Note: IsDisk() uses operating system functionalities. If a disk drive exists but has no disk inserted, the operating system prompts the user for inserting a disk.
To suppress this behavior, call SetErrorMode() and pass 1 to it.
| See also: | Directory(), DirChange(), DirRemove(), DiskChange(), DiskName(), File(), MakeDir(), SetErrorMode() |
| Category: | Disks and Drives , File functions , xHarbour extensions |
| Source: | rtl\dirdrive.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example collects drive letters in an array for all drives
// ready to use.
PROCEDURE Main
LOCAL aDisk := GetReadyDrives()
LOCAL cDisk
FOR EACH cDisk IN aDisk
? cDisk
END
? IsDisk( "A" )
RETURN
FUNCTION GetReadyDrives()
LOCAL aDrives := {}
LOCAL nDrive := 1
LOCAL nMode := SetErrorMode(1)
FOR nDrive := 1 TO 26
IF IsDisk( Chr( 64 + nDrive ) )
AAdd( aDrives, Chr( 64 + nDrive ) )
ENDIF
NEXT
SetErrorMode( nMode )
RETURN aDrives
http://www.xHarbour.com