HB_DirCreate

HB_DirCreate

Creates a directory

Syntax

      HB_DirCreate( <cNewDir>) --> <nSuccess>

Arguments

<cNewDir> : the name of the directory to be created, including an optional drive. If you do not specify a drive, the current one is used. The new directory can be specified relative to the current directory, or absolute, including a drive letter followed by a colon.

Return

<nSuccess> : zero on success, -1 if there is an argument error; Otherwise, HB_DirCreate() returns the DOS error code. HB_DirCreate() returns 0 if successful;

Description

HB_DirCreate() creates a specified directory. Note that first you must have sufficient rights to create a directory. To create nested subdirectories, you must create each subdirectory separately, starting from the top-level directory that you want to create (see example below.)

Note

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

Examples

      .  This example assumes that C:\TEST exists and uses HB_DirCreate()
         twice to create a nested subdirectory under it:

      HB_DirCreate("c:\test\one")    // Create top-most one
      nResult := HB_DirCreate("c:\test\one\two")
      IF nResult != 0
         ? "Cannot make directory, DOS error ", nResult
         BREAK
      ENDIF

      You may also use something like this:

      HB_DirCreate( ".\test" )

Seealso

DirChange(), DirName(), DirRemove(), MakeDir(), DirChange()

HB_DirBuild

HB_DirBuild

Creates a directory

Syntax

      HB_DirBuild( <cNewDir>) --> <nSuccess>

Arguments

<cNewDir> : the name of the directory to be created, including an optional drive. If you do not specify a drive, the current one is used. The new directory can be specified relative to the current directory, or absolute, including a drive letter followed by a colon.

Return

<nSuccess> : zero on success, -1 if there is an argument error; Otherwise, HB_DirBuild() returns the DOS error code. HB_DirBuild() returns 0 if successful;

Description

HB_DirBuild() creates a specified directory. Note that first you must have sufficient rights to create a directory. To create nested subdirectories, you must create each subdirectory separately, starting from the top-level directory that you want to create (see example below.)

Note

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

Examples

      .  This example assumes that C:\TEST exists and uses HB_DirBuild()
         twice to create a nested subdirectory under it:

      HB_DirBuild("c:\test\one")    // Create top-most one
      nResult := HB_DirBuild("c:\test\one\two")
      IF nResult != 0
         ? "Cannot make directory, DOS error ", nResult
         BREAK
      ENDIF

      You may also use something like this:

      HB_DirBuild( ".\test" )

Seealso

DirChange(), DirName(), DirRemove(), MakeDir(), DirChange(), HB_DirCreate(), DirMake()

ExeName

ExeName

Returns name and directory of the current Harbour program

Syntax

      ExeName() --> <cProgram>

Returns

<cProgram> : Drive, path and file name of the current .EXE program

Description

This function determines the name and path of the Harbour application in use

Note

This function is equivalent of HB_ArgV()

Example

      Determine if the name or path of an EXE file has changed:

      cOrigPath  :=  "C:\DATA\ADDRESS.EXE"
      IF ExeName() <> cOrigPath
         ? "Program name or directory have been changed!"
         QUIT
      ENDIF

Seealso

HB_ArgV(), HB_DirBase()

HB_DirBase

HB_DirBase

Drive and directory name of running executable ( application )

Syntax

      HB_DirBase() -> <cExeFolder>

Argument

None

Returns

<cExeFolder> : Folder name of running .exe

Description

HB_DirBase() returns folder name of application

Example :

      HB_DirBase() is equivalent to :

      LEFT( ExeName(), RAT( '\', ExeName() ) )

      and

      HB_FNameDir( ExeName() )

      and

      cExeDir := ''
      HB_FNameSplit( ExeName(), @cExeDir )

Seealso

HB_ArgV(), ExeName(), HB_FNameDir(), HB_FNameSplit()

HB_CWD

HB_CWD

Change working directory

Syntax

      HB_CWD( [ <cNewWD> ] ) -> <cPrevWD>

Argument

<cNewWD> : New working directory name to set

Return

<cPrevWD> : previous path if new one is set by optional parameter

Description

HB_CWD() can be use as DirName() and/or DirChange() depending on <cNewWD>.

Note

HB_CWD() seem as synonym of DirChange() with some extra features, such as : HB_CWD() function sets FError(). Programmer can check if HB_CWD() succeed checking result of FError() function, i.e.

          HB_CWD( cNewPath )
          IF FError() != 0
             ? "Cannot set working directory to:", cNewPath
          ELSE
             // stuff
          ENDIF

Example

      ? HB_CWD()
      ? HB_CWD( '\TEMP' )

Seealso

DirName(), DirChange()

DirName

DirName

Returns the current directory name

Syntax

      DirName( [<cDrive>] ) --> <cCurDirName>

Argument

<cDrive> : Designates the drive for which the current directory is determined (a colon is unnecessary). The default is the current drive.

Return

<cCurDirName> : name of the current directory as a character string. The string does not include a drive letter.

Description

DirName() determines the current directory name on the selected drive. You can use this function to construct complete access paths.

Note

DirName() seem as a synonim of CurDir() and doesn’t support <cDrive> properly

Example

      ? '  ->', DirName(), CurDir()              //    -> \temp temp
      ?
      ? DirChange( 'C:\TEMP' )                   //           0
      ? DirChange( 'D:\TEMP' )                   //           0
      ? DirChange( 'E:\TEMP' )                   //           0
      ?
      ? 'C ->', DirName( 'C' ), CurDir( 'C' )    //  C -> \
      ? 'D ->', DirName( 'D' ), CurDir( 'D' )    //  D -> \
      ? 'E ->', DirName( 'E' ), CurDir( 'E' )    //  E -> \
      ?                                          //
      ? 'C:->', DirName( 'C:' ), CurDir( 'C:' )  //  C:-> \
      ? 'D:->', DirName( 'D:' ), CurDir( 'D:' )  //  D:-> \
      ? 'E:->', DirName( 'E:' ), CurDir( 'E:' )  //  E:-> \

Files

lib : hbct

Seealso

CurDir(), DirChange(), DirMake(), DirRemove()

DirMake

DirMake

Creates a directory

Syntax

      DirMake( <cNewDir>) --> <nSuccess>

Arguments

<cNewDir> : the name of the directory to be created, including an optional drive. If you do not specify a drive, the current one is used. The new directory can be specified relative to the current directory, or absolute, including a drive letter followed by a colon.

Return

<nSuccess> : zero on success, -1 if there is an argument error; Otherwise, DirMake() returns the DOS error code. DirMake() returns 0 if successful;

Description

DirMake() creates a specified directory. Note that first you must have sufficient rights to create a directory. To create nested subdirectories, you must create each subdirectory separately, starting from the top-level directory that you want to create (see example below.)

Note

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

Examples

      .  This example assumes that C:\TEST exists and uses DirMake()
         twice to create a nested subdirectory under it:

      DirMake("c:\test\one")    // Create top-most one
      nResult := DirMake("c:\test\one\two")
      IF nResult != 0
         ? "Cannot make directory, DOS error ", nResult
         BREAK
      ENDIF

      You may also use something like this:

      DirMake( ".\test" )

Seealso

DirChange(), DirName(), DirRemove(), MakeDir(), DirChange(), HB_DirCreate(), HB_DirBuild()

HB_FileMatch

HB_FileMatch

Makes a DOS style file mask comparison

Syntax

      HB_FileMatch( <cFile>, <cPattern> ) -> <lMatch>

Argument

<cFile> : File name to compare

<cPattern> : File mask; file specification including wildcard characters ( *, ? )

Returns

<lMatch> : .T. if <cFile> matche with <cPattern>, else .F:

Description

This func makes a DOS style widcard comparison between given filename and mask (skeleton).

BTW HB_DirScan() uses internally HB_FileMatch().

Example

      LOCAL cTestFName := "C:\temp\test.tmp"

        ? 'File  ', FILE( cTestFName )                   // .T.
        ? 'C     ', HB_FileMatch( cTestFName, 'C' )      // .F.
        ? ':     ', HB_FileMatch( cTestFName, ':' )      // .F.
        ? 'C:    ', HB_FileMatch( cTestFName, 'C:' )     // .F.
        ? 'temp  ', HB_FileMatch( cTestFName, 'temp' )   // .F.
        ? '*temp ', HB_FileMatch( cTestFName, '*temp' )  // .F.
        ? '*temp*', HB_FileMatch( cTestFName, '*temp*' ) // .T.
        ? 'test  ', HB_FileMatch( cTestFName, 'test' )   // .F.
        ? '.tmp  ', HB_FileMatch( cTestFName, '.tmp' )   // .F.
        ? '*tmp  ', HB_FileMatch( cTestFName, '*tmp' )   // .T.

Seealso

HB_DirScan(), FileSeek(), Directory()

Directory

Directory

Build an array of Directory and file information

Syntax

      Directory( <cDirSpec>, [<cAttributes>] ) --> aDirectory

Arguments

<cDirSpec> : identifies the drive, Directory and file specification for the Directory search. Wildcards are allowed in the file specification. If <cDirSpec> is omitted, the default value is *.*.

<cAttributes> : specifies inclusion of files with special attributes in the returned information. <cAttributes> is a string containing one or more of the following characters:

          Directory() Attributes
          ---------------------------------------------------------
          Attribute Meaning
          ---------------------------------------------------------
              H     Include hidden files
              S     Include system files
              D     Include directories
              V     Search for the DOS volume label and exclude all
                    other files
          ---------------------------------------------------------

Normal files are always included in the search, unless you specify V.

Returns

Directory() returns an array of subarrays, with each subarray containing information about each file matching <cDirSpec>. The subarray has the following structure:

          Directory() Subarray Structure
          ----------------------------------------------------------
          Position Metasymbol  Directry.ch
          ----------------------------------------------------------
             1     cName       F_NAME
             2     cSize       F_SIZE
             3     dDate       F_DATE
             4     cTime       F_TIME
             5     cAttributes F_ATTR
          ----------------------------------------------------------

If no files are found matching <cDirSpec> or if <cDirSpec> is an illegal path or file specification, Directory() returns an empty ({}) array.

Description

Directory() is an environment function that returns information about files in the current or specified Directory. It is similar to ADIR(), but returns a single array instead of adding values to a series of existing arrays passed by reference. Use Directory() to perform actions on groups of files. In combination with AEVAL(), you can define a block that can be applied to all files matching the specified <cDirSpec>. The header file, Directry.ch, in the \CLIP53\INCLUDE subDirectory contains #defines for the subarray subscripts, so that the references to each file subarray are more readable.

Examples

      This example creates an array of information about files in the current
      Directory and then lists the names of the files using AEVAL() and QOUT():

      #include "Directry.ch"
      //
      aDirectory := Directory("*.*", "D")
      AEVAL( aDirectory, {| aFile | QOUT( aFile[ F_NAME ])} )

      #include "Directry.ch"

      PROC Main()

         LOCAL cFileSpec := "C:\hb32\*.*"

         LOCAL aFileList := Directory( cFileSpec, "D")

          LOCAL nMaxFNmLen := 0

         SET CENT ON
         SET DATE GERM

         AEVAL( aFileList, { | a1File | nMaxFNmLen := ;
                             MAX( nMaxFNmLen, LEN( a1File[ F_NAME ] ) ) } )

         AEVAL( aFileList, { | a1File | ;
                             QOUT( PADR( a1File[ F_NAME ], nMaxFNmLen + 1 ),;
                             TRAN( a1File[ F_SIZE ], "999,999,999" ),;
                             a1File[ F_DATE ],;
                             a1File[ F_TIME ],;
                             a1File[ F_ATTR ] ) } )

         ?
         WAIT "End of Directory.prg"

      RETU // Directory.Main()

      Result of Directory.prg :

      .                   0 13.09.2012 02:07:15 D
      ..                  0 13.09.2012 02:07:15 D
      addons              0 13.09.2012 02:07:07 D
      bin                 0 13.09.2012 02:07:12 D
      ChangeLog   8,848,829 12.09.2012 01:59:44 A
      comp                0 13.09.2012 02:07:12 D
      contrib             0 13.09.2012 02:07:16 D
      COPYING        47,456 12.09.2012 01:59:44 A
      doc                 0 13.09.2012 02:07:07 D
      extras              0 13.09.2012 02:07:15 D
      include             0 13.09.2012 02:07:07 D
      INSTALL        79,968 12.09.2012 01:59:44 A
      lib                 0 13.09.2012 02:07:14 D
      NEWS          108,058 12.09.2012 01:59:44 A
      RELNOTES        9,832 18.04.2012 04:00:10 A
      tests               0 13.09.2012 02:07:15 D
      TODO            2,924 12.09.2012 01:59:44 A
      uninstall.exe 104,646 13.09.2012 02:07:12 A

      End of Directory.prg

Seealso

ADir(), FileSeek(), HB_FileMatch()

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()