xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

IsDisk()

Verify if a drive is ready

Syntax

IsDisk( <cDrive> ) --> lDriveIsReady

Arguments

<cDrive>
This is single character specifying the drive letter of the disk drive to check for readiness.

Return

The function returns .T. (true) if the disk drive <cDrive> is ready, otherwise .F. (false)

Description

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.

Info

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

Example

// 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

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