FileCOpen

FileCOpen

Tests to see if the file is still open in the backup mode

Syntax

      FileCOpen() --> <lOpenFile>

Returns

<lOpenFile> : .T. when all data is not copied during a FileCopy() or FileCCont().

Description

FILE COPY OPEN

FileCOpen() determines whether all data is copied. This concerns the source file, which is specified when the FileCopy() function is called. FileCOpen() returns .T. until all the data in the source file is read, whether by FileCopy or the follow-on function FileCCont()

Note

. If you must abort the copy process, and FileCOpen() continues to returns .T., use FileCClose().

Examples

      Show a back up with FileCopy():

      nCounter   := 1                   // "BIG.001" etc.
      cTargetFile   := "BIG" + NTOC(nCounter, 10, 3, "0")
      FileCopy("BIG.DBF", "A:\" + cTargetFile, .T.)
                                        // Back up mode
      DO WHILE FileCOpen()
         DO NEXTDISK                    // Request disk change
         nCounter     := nCounter + 1
         cTargetFile  := "BIG" + NTOC(nCounter, 10, 3, "0")
         FileCCont(cTargetFile)         // Next disk - new name

      ENDDO
      FileCClose()                      // For safety

Seealso

FileCopy(), FileCCont(), FileCClose(), FileCDaTi()

FileCDaTi

FileCDaTi

Determines which date the target file contains with a FileCopy().

Syntax

      FileCDaTi([<lNewMode>]) --> <lOldMode>

Argument

<lNewMode> : Designates the new status for FileCDaTi(). When .T. is designated, the target file contains the source file date; when it is .F., the system date. The default is the source file date (.T.).

Returns

If no parameter is designated, FileCDaTi() returns the current setting for FileCDaTi(); otherwise, it returns the previous setting.

Description

FILE COPY DATE TIME

FileCDaTi() Determines whether a source file’s date and time stamp or the system’s date and time stamp, should be used to create or copy a file. Use original or system time for a file copy process.

When you partition to several disks in backup mode, this concerns all target files. Default is .T., where the target file contains the date and time of the source file. If you call FileCDaTi() with the parameter designated .F., then the target file contains the system date and time.

Notes

. Use this function before FileCopy().

. If the target file contains a unique setting such as a pseudo serialization, use the SETFDATI() function.

Examples

      .  Query the FileCDaTi() setting:
         ? FileCDaTi()            // The current setting
      .  The target file is to contain the system date and time:
         ? FileCDaTi(.F.)         // Returns the previous setting

Seealso

FileCopy(),  FileCCont(), FileCClose()

FileCCont

FileCCont

Copies sections of a file in backup mode

Syntax

      FileCCont(<cFile>) --> <nCopyByte>

Argument

<cFile> : The file name for the target file.

Returns

<nCopyByte> : number of bytes copied

Description

FILE COPY CONTINUE

Use this function primarily after a FileCopy(). As much as possible of the remaining data is written to a new disk. If the remaining data still does not fit on the designated target disk, call this function repeatedly until it writes all the remaining data. Each time you call FileCCont(), a new name can be designated for the target file. These files are then numbered consecutively (see Examples).

Notes

. If a copy procedure on multiple disks terminates for any reason, call FileCClose().

. Use SETFCREATE() to designate an attribute to form a new file.

. The function acknowledges the CSETSAFETY() implementation, as does FileCopy()

Example

      . Show a back up with FileCopy().  After terminating, close the source
      file:

      FileCopy(cSource, cTarget, .T.)   // Back up mode
      DO NEXTDISK                       // When terminated  Terminated = .T.
      DO WHILE FILECOPEN() .AND. .NOT. Terminated
         FileCCont(cTarget)             // Next disk, new name
         DO NEXTDISK                    // Request for disk exchange
      ENDDO
      IF Terminated
         FileCClose()                   // Close source file!
      ENDIF

Seealso

FileCopy(), FileCOpen(), FileCClose(), FileCDaTi()

FileCClose

FileCClose

Closes a file after backup mode

Syntax

      FileCClose() --> <lClosed>

Returns

<lClosed> : .T., when the the file that was opened with FileCopy() is successfully closed.

Description

FILE COPY CLOSE

After you copy on multiple disks, this function should be routinely called. This is to prevent the source file, previously designed with FileCopy(), from remaining open. For example, this may occur if you terminate the copy procedure.

Note

. Regardless of the share mode, all other users are not allowed access. This situation stays this way without needing a file handle.

Example

      Show a back up with FileCopy().  After terminating, close the source
      file:

      FileCopy(cSource, cTarget, .T.)      // Back up mode
      DO NEXTDISK                          // When terminated Terminated = .T.
      DO WHILE FileCOpen() .AND. .NOT. Terminated
         FileCCont(cTarget)                // Next disk, new name
         DO NEXTDISK                       // Request for disk exchange
      ENDDO
      IF Terminated
         FileCClose()                      // Close source file!
      ENDIF

Seealso

FileCopy(), FileCCont(), FileCOpen(), FileCDaTi()

HB_PathNormalize

HB_PathNormalize

Normalizes the path designation by converting relative path to absolute

Syntax

      HB_PathNormalize( <cRPath> ) -> <cAPath>

Argument

<cRPath> : A path as relative ( include one or more ‘.’ and / or ‘..’ ). It is assumed that it is in accordance with OOS rules.

Returns

<cAPath> : Normalized ( absolute ) path, standardized path whenever possible.

Description

HB_PathNormalize() looks like a synonym of TrueName()

Example

      LOCAL cDir := 'C:\temp\TestSeps'
      ? HB_PathNormalize( cDir + "\.." )  // C:\temp

Seealso

HB_DirSepAdd(), HB_DirSepDel(), HB_DirSepToOS(), TrueName()

HB_DirUnbuild

HB_DirUnbuild

Attempt to remove a directory

Syntax

      HB_DirUnbuild( <cDir> ) -> <lSuccess>

Argument

<cDir> : The name of the directory to delete

Returns

<lSuccess> : A logical value denotes either <cDir> removed or not

Description

This function attempt to remove the specified directory <cDir> and return .T. if deletion is successfull, else .F.

Note

<cDir> must be empty HB_DirUnbuild() look like a synonym of DirRemove() and HB_DirDelete(); difference is in return value.

Example

      PROC TstDirUnbld()
         LOCAL cDir := 'C:\temp\TstUnB'

         ? 'Is', CDir, 'exists ?    ', HB_DirExists( cDir )   // .T.
         ? 'Is', CDir, 'UnBuilded ? ', HB_DirUnbuild( cDir )  // .F. (*)
         ? 'Is', CDir, 'exists now ?', HB_DirExists( cDir )   // .F.

      RETU // TstDirUnbld()

      (*) observed that <cDir> not found after operation

Seealso

DirRemove(), HB_DirDelete()

HB_DirTemp

HB_DirTemp

Returns name of temp dir of system / user, with closing backslash

Syntax

      HB_DirTemp() -> <SysTempDirName>

Argument

None

Result

<SysTempDirName> : name of temp dir of system / user

Description

HB_DirTemp() is an environment function to obtain name of temp dir of system / user.

This info can be get by SET TEMP command in cmd box and by GETE() function also (see example).

Note that Harbour add a dir-separator (backslash for Windows) to end of <SysTempDirName>.

In Windows, this is : C:\Users\<CurrentUser>\AppData\Local\Temp

Example

      ? HB_DirTemp()
      ? GETE( 'TEMP' )

Seealso

GETE(), GETENV(), HB_GetEnv()

HB_DirSepToOS

HB_DirSepToOS

Convert dir separators in a path to OS standard dir separators

Syntax

      HB_DirSepToOS( <cPath1> ) -> <cPath2>

Argument

<cPath1> : A path with any dir separator in it

Returns

<cPath2> : Converted dir separators to OS standard version of <cPath1>

Description

In paths, “dir separator” is a ‘\’ ( back slash ) for DOS / Windows and a “/” ( slash )for U*nix systems

HB_DirSepToOS() is a function to convert dir separators to OS standard

Example

      LOCAL cDir := 'C:/temp/TestSeps'
      ? HB_DirSepToOS( cDir  )            // C:\temp\TestSeps

Seealso

HB_PathNormalize(), HB_DirSepAdd(), HB_DirSepDel(), TrueName()

HB_DirSepDel

HB_DirSepDel

Delete dir separator at end of a path if exists

Syntax

      HB_DirSepDel( <cPath1> ) -> <cPath2>

Argument

<cPath1> : A path either include or not a dir separator at end

Returns

<cPath2> : Absent dir separator at end version of <cPath1>

Description

In paths, “dir separator” is a ‘\’ ( back slash ) for DOS / Windows and a “/” ( slash )for U*nix systems

HB_DirSepAdd() is a function to delete dir separator to end of a path if it’s exist

Example

      LOCAL cDir := 'C:\temp\TestSeps\'
      ? HB_DirSepDel( cDir )  // C:\temp\TestSeps

Seealso

HB_PathNormalize(), HB_DirSepAdd(), HB_DirSepToOS(), TrueName()

HB_DirSepAdd

HB_DirSepAdd

Add a dir separator to end of a path when its missing

Syntax

      HB_DirSepAdd( <cPath1> ) -> <cPath2>

Argument

<cPath1> : A path either include or not a dir separator at end

Returns

<cPath2> : Added dir separator at end version of <cPath1>

Description

In paths, “dir separator” is a ‘\’ ( back slash ) for DOS / Windows and a “/” ( slash )for U*nix systems

HB_DirSepAdd() is a function to add a dir separator to end of a path when its missing

Example

      LOCAL cDir := 'C:\temp\TestSeps'
      ? HB_DirSepAdd( cDir )          // C:\temp\TestSeps\

Seealso

HB_PathNormalize(), HB_DirSepDel(), HB_DirSepToOS(), TrueName()