TrueName

TrueName

Standardizes the path designation by converting relative path to absolute

Syntax

      TrueName( <cPathDesignation> ) --> <cStandardizedPath>

Argument

<cPathDesignation> : Designates a path as a standard. It is assumed that it is in accordance with DOS rules.

Returns

<cStandardizedPath> : returns the standardized path whenever possible.

Description

Path designations are made for the drive as well as the path itself, with regard to the current position designation. With TrueName(), related path designations are changed around so that they relate to the root directory of a particular drive.

The function does not test to see if a path exists. If the designated path is not valid or the specified drive is unavailable, it returns a null string.

Note

Warning! Additional information is built into the path of network drives. Under PC-LAN/MS-NET, the path contains the designation:\\<ServerName>. Under Novell, \\<ServerName>\ <VolumeName> (see Examples).

Examples

      ? CurDir()                    // temp
      ? TrueName(".")                  // C:\temp
      DirChange( "\temp" )
      ? TrueName( "." )                // C:\temp
      DirChange( "dir1" )
      ? CurDir()                       // temp\dir1
      ? TrueName( "." )                // C:\temp\dir1
      ? TrueName( ".." )               // C:\temp

      .  Anything valid under DOS is acceptable:

         ? TrueName("..\..\TEST1\.\TEST2")      // e.g. "C:\TEST1\TEST2"

      .  In a Novell network, remove tokens 2 and 3, server name, and
         volume name:

         IF NNETWORK()
            cPath   := TrueName(cOldPath)
            cToken1 := TOKEN(cPath, ":\", 1)
            cToken2 := TOKEN(cPath, ":\", 2)
            cToken3 := TOKEN(cPath, ":\", 3)
            cPath   := cToken1 + AFTERATNUM(cToken2 + cToken3, cPath)
          ENDIF

Files

Lib is hbct

Seealso

TOKEN(), AFTERATNUM()

HB_DirScan

HB_DirScan

Scan a directory tree and build a files and folders list

Syntax

      hb_DirScan(<cPath>, [<cFileMask>], [<cAttr>]) --> <aFiles>

Arguments

<cPath> : A character string holding the drive, directory and/or file specification to retrieve information for. Default is current directory.

<cFileMask> : For filter files to add to the list, (can include wild card characters). Default is ‘*.*’.

<cAttr> : A character string holding file attributes can be specified. Information about files carrying these attributes is retrieved. One or more characters of the table below can be included in . For add directories to the list add ‘D’ to .

Attributes for HB_DirScan() :

         Attribute Meaning
         --------- -------------------------
             A     Archive
             D     Directories
             H     Hidden files
             R     Read-only
             S     System files

Returns

<aFiles> : A two-dimensional array of five columns; holding information about files in the and the that match . An empty array, if no matched file found or an error occured.

Description

The HB_DirScan() function is similair to the Directory(). The first difference is that HB_DirScan() scans recursively all sub- directories in the directory specified with. And second difference is Directory() don’t requires parameter, instead this info included in the .

The result is a two dimensional array . Columns can be accessed using #define constants from the DIRECTRY.CH file.

Constants for the HB_DirScan() array :

         Symbolic Numeric
         Constant Value  Meaning             Data Type
         -------- -----  ------------------- --------------
         F_NAME     1    File name           Character
         F_SIZE     2    File size in bytes  Numeric
         F_DATE     3    File date           Date
         F_TIME     4    File time           Character
         F_ATTR     5    File attributes     Character

Files

Header: Directry.ch

Example

      Assuming this directory tree and files exist :

      C:\
         | temp                     D
         + ---- + Dir1              D
                |      doc1.docx    F
                |      test1.bat    F
                |      test1.txt    F
                + Dir2              D
                |      doc2.docx    F
                |      test2.bat    F
                |      test2.txt    F
                + run.bat           F
                  test.bat          F
                  test.exe          F

      PROC TestDScan()

         LOCAL aFFList := HB_DirScan( "C:\TEMP" )

         LOCAL x1Row

         FOR EACH x1Row IN aFFList
            ? PAD( x1Row[ 1 ], 23 ),;                     // Name
              TRAN( x1Row[ 2 ], '999,999,999,999' ),;     // Size
              x1Row[ 3 ],;                                // Date
              x1Row[ 4 ],;                                // Time
              x1Row[ 5 ]                                  // Attributes
         NEXT x1Row

      RETU // TestDScan()

      Result :

         Dir1\doc1.docx       14,757 26.02.2014 00:04:27 A
         Dir1\test1.bat           54 24.02.2014 00:54:01 A
         Dir1\test1.txt           54 24.02.2014 00:54:01 A
         Dir2\doc2.docx       14,757 26.02.2014 00:04:27 A
         Dir2\test2.bat           54 24.02.2014 00:54:01 A
         Dir2\test2.txt           54 24.02.2014 00:54:01 A
         run.bat               24 27.02.2014 01:12:28 A
         test.bat                 54 24.02.2014 00:54:01 A
         test.exe          1,413,285 27.02.2014 01:10:36 A

      ˜˜˜˜˜˜˜

      HB_DirScan( "C:\TEMP\*.txt" ) <- Incorrect call !

      ˜˜˜˜˜˜˜

      HB_DirScan( "C:\TEMP\", "*.txt" )

      Result :

         Dir1\test1.txt           54 24.02.2014 00:54:01 A
         Dir2\test2.txt           54 24.02.2014 00:54:01 A

Seealso

Directory(), File(), FileSeek(), HB_FileMatch()HB_FileExists(), HB_FNameExists(), HB_DirExists()FileFindXxxx