HB_CurDrive

HB_CurDrive

Return the current OS drive

Syntax

      HB_CurDrive() --> cDrive
     

Returns

HB_CurDrive() returns the letter of the current DOS drive, without a trailing colon.

Examples

      ? HB_CurDrive()        // D
      ? DiskChange()      // .F.
      ? DiskChange( "C" ) // .T.
      ? HB_CurDrive()        // C
      
      .  This example illustrates the relationship between
         HB_CurDrive()and DISKCHANGE() and shows that HB_CurDrive() is unaffected by
         the SET DEFAULT TO command:
      
      ? HB_CurDrive()      // C
      SET DEFAULT TO A
      ? HB_CurDrive()      // C
      DISKCHANGE("A")
      ? HB_CurDrive()      // A
      DISKCHANGE("C")
      ? HB_CurDrive()      // C
     

Seealso

CurDir(), DiskChange(), DiskName()

DiskChange

DiskChange

Change the current DOS disk drive

Syntax

      DiskChange(<cDrive>) --> lSuccess

Arguments

<cDrive> : specifies the letter of the disk drive to change to

Returns

DiskChange() returns true (.T.) if successful; otherwise, it returns false (.F.).

Examples

      ? DiskName()        // D
      ? DiskChange()      // .F.
      ? DiskChange( "C" ) // .T.
      ? DiskName()        // C

      .  This example uses DiskChange() to change to drive "D":

      IF DiskChange("D:")
         ? "Successfully changed"
      ELSE
         ? "Not changed"
      ENDIF

      .  This example builds a string that contains all currently
         available drives on your system:

       PROCEDURE Main()
           ? DriveList()
           ?
           WAIT "EOF DiskChange.prg"
       RETURN // DiskChange.Main()

       *˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

       FUNCTION DriveList()

          LOCAL nDriveNo := 0,;
                c1Drive  := '',;
               cRetVal  := "",;
               cCurrent := DiskName()

          FOR nDriveNo := 1 TO 26
             c1Drive := CHR( nDriveNo + 64)
             IF DiskChange( c1Drive )
                cRetVal += c1Drive
             ENDIF
          NEXT

         DiskChange( cCurrent )  // Restore current drive

       RETURN cRetVal // DriveList()

Seealso

DiskName()

MakeDir

MAKEDIR()

Create a new directory

Syntax

      MAKEDIR( <cDirectory> ) --> nError

Arguments

<cDirectory> The name of the directory you want to create.

Returns

<nError> 0 if directory was successfully created, otherwise the number of the last error.

Description

This function attempt to create a new directory with the name contained in <cDirectory>. If this function fails, it will return the last OS error code number. See FERROR() function for the description of the error

Note

     MakeDir() is equivalent to DirMake(), HB_DirCreate() and HB_DirBuild()

Examples

      cDir := "temp"
      IF MakeDir( cDir ) == 0
         ? "Directory", cDir, "successfully created"
      ENDIF

Tests

      See examples

Compliance

This function is CA-Cl*pper 5.3 compliant

Platforms

All

Files

Library is rtl

Seealso

DIRCHANGE(), DIRREMOVE(), ISDISK(), DISKCHANGE(), DISKNAME(), FERROR(), DirMake(), HB_DirCreate(), HB_DirBuild()

IsDisk()

ISDISK()

Verify if a drive is ready

Syntax

      ISDISK( <cDrive> ) --> lSuccess

Arguments

<cDrive> An valid Drive letter

Returns

<lSuccess> .T. is the drive is ready, otherwise .F.

Description

This function attempts to access a drive. If the access to the drive was successfull, it will return true (.T.), otherwise false(.F.). This function is usefull for backup function, so you can determine if the drive that will receive the backup data is ready or not.

Examples

      IF IsDisk( "A" )
         ? "Drive is ready "
      ENDIF

Tests

      See Examples

Compliance

This function is CA-Cl*pper 5.3 compliant

Platforms

All

Files

Library is rtl

Seealso

DIRCHANGE(), MAKEDIR(), DIRREMOVE(), DISKCHANGE(), DISKNAME()

DirRemove()

DIRREMOVE()

Attempt to remove a directory

Syntax

      DIRREMOVE( <cDirectory> ) --> nError

Arguments

<cDirectory> The name of the directory you want to remove.

Returns

<nError> 0 if directory was successfully removed, otherwise the number of the last error.

Description

This function attempt to remove the specified directory in <cDirectory> If this function fails, it will return the last OS error code number. See FERROR() function for the description of the error.

Examples

      cDir := ".\backup"
      IF DirRemove( cDir ) == 0
         ? "Remove of directory", cDir, "was successfull"
      ENDIF

Tests

      See examples

Compliance

This function is CA-Cl*pper 5.3 compliant

Platforms

All

Files

Library is rtl

Seealso

MAKEDIR(), DIRCHANGE(), ISDISK(), DISKCHANGE(), DISKNAME(), FERROR()

DirChange()

DIRCHANGE()

Changes the directory

Syntax

      DIRCHANGE( <cDirectory> ) --> nError

Arguments

<cDirectory> The name of the directory you want do change into.

Returns

<nError> 0 if directory was successfully changed, otherwise the number of the last error.

Description

This function attempt to change the current directory to the one specified in <cDirectory>. If this function fails, it will return the last OS error code number. See FERROR() function for the description of the error.

Examples

      IF DirChange( "\temp" ) == 0
         ? "Change to diretory was successfull"
      ENDIF

Tests

      See examples

Compliance

This function is CA-Cl*pper 5.3 compliant

Platforms

All

Files

Library is rtl

Seealso

MAKEDIR(), DIRREMOVE(), ISDISK(), DISKCHANGE(), DISKNAME(), FERROR()

C5_DISKNAME

 DISKNAME()
 Return the current DOS drive
------------------------------------------------------------------------------
 Syntax

     DISKNAME() --> cDrive

 Returns

     DISKNAME() returns the letter of the current DOS drive, without a
     trailing colon.

 Examples

     .  This example illustrates the relationship between
        DISKNAME()and DISKCHANGE() and shows that DISKNAME() is unaffected by
        the SET DEFAULT TO command:

        ? DISKNAME()      // C
        SET DEFAULT TO A
        ? DISKNAME()      // C
        DISKCHANGE("A")
        ? DISKNAME()      // A
        DISKCHANGE("C")
        ? DISKNAME()      // C

 Files   Library is EXTEND.LIB.

See Also: CURDIR() DISKCHANGE()

 

CT_DISKNAME

 DISKNAME()
 Determines the drive designator for the current drive

 Syntax

     DISKNAME() --> cDrive

 Returns

     DISKNAME() returns a letter that identifies the designator as the
     current drive.

 Description

     DISKNAME() determines the current drive designator for the construction
     of complete path names.

 Note

     .  The designator does not contain a colon.

 Example

     Display the drive designator for the current drive:

     ? DISKNAME()      // Returns a "C" with most hard disk systems

See Also: DIRNAME()

Tools — Disk Utilities

Introduction Disk Utilities
DELETEFILE() Deletes an error-tolerant file
DIRCHANGE()  Changes the current directory
DIRMAKE()    Creates a directory
DIRNAME()    Determines the name of the current directory
DIRREMOVE()  Removes a directory
DISKCHANGE() Changes the current disk drive
DISKCHECK()  Creates a checksum for a disk
DISKFORMAT() Formats disks, controlled through a UDF
DISKFREE()   Determines the space available on a floppy or hard disk
DISKNAME()   Determines the drive designator for the current drive
DISKREADY()  Tests to see if a disk drive is ready
DISKREADYW() Queries whether you can write to a drive
DISKSPEED()  Determines a comparison value for the drive speed
DISKSTAT()   Determines the status of a drive.
DISKTOTAL()  Determines the total capacity of a floppy or hard disk
DISKTYPE()   Determines the type of data carrier
DRIVETYPE()  Determines the drive type
FILEAPPEND() Appends data to a file
FILEATTR()   Determines a file's attributes
FILECCLOSE() Closes a file after backup mode
FILECCONT()  Copies sections of a file in backup mode
FILECDATI()  Determines which date the target file contains with FILECOPY()
FILECHECK()  Calculates/computes/determines a checksum for a file
FILECOPEN()  Tests to see if the file is still open in the backup mode
FILECOPY()   Copies files normally or in backup mode
FILEDATE()   Determines the file date
FILEDELETE() Deletes file(s) by name and attribute
FILEMOVE()   Moves files to another directory
FILESEEK()   Searches for files by name and attribute
FILESIZE()   Determines the size of a file
FILESTR()    Reads a portion of a file into a string
FILETIME()   Determines a file's time
FILEVALID()  Tests whether a string has a valid file name
FLOPPYTYPE() Determines the exact type of floppy drive
GETSHARE()   Determines the file open (share) mode
NUMDISKF()   Determines the number of installed disk drives
NUMDISKH()   Determines the number of hard disks
NUMDISKL()   Determines the number of available logical drives
RENAMEFILE() Fault tolerant renaming of a file.
RESTFSEEK()  Restores the FILESEEK environment
SAVEFSEEK()  Saves the current FILESEEK environment
SETFATTR()   Sets a file's attributes
SETFCREATE() Default attribute for creating with CA-Clipper Tools functions
SETFDATI()   Sets the date and time of a file
SETSHARE()   Sets default opening mode for CA-Clipper Tools file functions
STRFILE()    Writes a string to a file
TEMPFILE()   Creates a file for temporary use
TRUENAME()   Standardizes the path designation
VOLSERIAL()  Determines the DOS disk serial number
VOLUME()     Establishes a volume label for a floppy or hard disk

DIRCHANGE() Function

DIRCHANGE() Function Sample

/*
DIRCHANGE()

    Change the current DOS directory

Syntax :

DIRCHANGE( <cDir> ) –> nSuccess

Arguments :

<cDir> is the name of the directory to change to, including the drive.

Returns :

   DIRCHANGE() returns 0 if successful; -1 if there is an argument error. Otherwise, DIRCHANGE() returns the DOS error code.

Description :

  DIRCHANGE() changes the current DOS directory. This function may also be used to determine whether or not a directory exists.

Examples :

  The following example attempts to change to the “c:\dos” directory. If it is unsuccessful, an error message is displayed.

 nResult := DIRCHANGE("c:\dos")
 IF nResult != 0
    ? "Cannot change directory. "
    DO CASE
      CASE nResult == 3
         ?? "Directory does not exist."
      CASE nResult == 5
         ?? "Access to directory denied."
    ENDCASE
    BREAK
 ENDIF

 You may also use something like this:
 DIRCHANGE( "..\..\test" )

 Remarks :

    If <cDir> includs drive specifier, DIRCHANGE() also changes the current drive.

*/

PROC DirChTest()
    LOCAL cDirToChange := "c:\harbour"

    LOCAL cCurDrive := DISKNAME()

    LOCAL nResult

    ? "Current Drive is :", cCurDrive

    nResult := DIRCHANGE( cDirToChange )
    IF nResult = 0
       cCurDrive := DISKNAME()
       ? "Current directory of drive", cCurDrive, "changed to :", CURDIR()
    ELSE
       ? "Cannot change directory to", cDirToChange, ": "
       DO CASE
          CASE nResult = 2
             ?? "File does not exist."
          CASE nResult = 3
             ?? "Directory does not exist."
          CASE nResult = 5
             ?? "Access to directory denied."
          CASE nResult = 15
             ?? "Invalid Drive was specified."
          CASE nResult = 21
             ?? "Drive not ready." 
          OTHE 
             ?? "Unknown error !", nResult
       ENDCASE
    ENDIF

    // Inspect dir existence :
    cDirToChange := "C:\TEMP"
    ? DISKNAME() + ":\" + CURDIR()
    ? cDirToChange, "directory is", IF( IsThisADir( cDirToChange ),;
                                        "", "not" ), "exists." 
    ? DISKNAME() + ":\" + CURDIR()
    ?
    WAIT "End of DIRCHANGE.PRG"

RETU // DirChTest()

/*
 Using DIRCHANGE() function to determine whether or not a directory exists.
*/

FUNC IsThisADir( cDirSpec )
   LOCAL cCurrent := DISKNAME() + "\" + CURDIR(),;
         lRetval := .F.

   IF !EMPTY( cDirSpec )
      lRetval := ( DIRCHANGE( cDirSpec ) = 0 )
      DIRCHANGE( cCurrent )
   ENDIF

RETU lRetval // IsThisADir()