CT_FILECHECK

 FILECHECK()
 Calculates/computes/determines a checksum for a file

 Syntax

     FILECHECK(<cFile>) --> nCheckSum

 Argument

     <cFile>  Designates which file name (with path, if required), to
     check.

 Returns

     FILECHECK() returns a checksum value for <cFile>.

 Description

     FILECHECK() determines if there have been changes or read errors in a
     file, and then takes note of data backup.  This also allows you to
     protect your hard disk from simple viruses (see Examples).

 Note

     .  You must specify the argument.  If it is omitted or an
        unavailable file is specified, FILECHECK() returns an error code of -
        1.  You may use a drive and access path, but no wildcards.

 Examples

     .  Check database for changes:

        IF FILECHECK("CUST.DBF") <> Old_ChkSum
           ? "Warning! Data back-up required."
        ENDIF

     .  Check COMMAND.COM for changes:

        IF FILECHECK("\COMMAND.COM") <> Cmd_ChkSum
           ? "COMMAND.COM has been changed! Caution, Virus!"
        ENDIF

See Also: DISKCHECK() SETSHARE()

Advertisements

CT_FILECDATI

 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 copy

 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 which date the target file contains with a
     FILECOPY().  When you partition to several disks in backup mode, this
     concerns all target files.  The CA-Clipper Tools 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

See Also: FILECOPY() SETFDATI()

CT_FILECCONT

 FILECCONT()
 Copies sections of a file in backup mode
------------------------------------------------------------------------------
 Syntax

     FILECCONT(<cFile>) --> nCopyByte

 Argument

     <cFile>  Designates the file name for the target file.

 Returns

     FILECCONT() returns the 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

See Also: FILECOPY() FILECOPEN() FILECCLOSE() FILECDATI()

CT_FILECCLOSE

 FILECCLOSE()
 Closes a file after backup mode

 Syntax

     FILECCLOSE() --> lClosed

 Returns

     FILECCLOSE() returns .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

See Also: FILECOPY() FILECCONT() FILECOPEN()

CT_FILEATTR

 FILEATTR()
 Determines a file's attributes
------------------------------------------------------------------------------
 Syntax

     FILEATTR([<cFile>]) --> nFileAttr

 Argument

     <cFile>  Designates the file name, including the path and drive
     designation.

 Returns

     FILEATTR() returns the attributes for the researched entry or the
     attribute from the FILESEEK() buffer (when called without a parameter).

 Description

     FILEATTR() is implemented alone or in conjunction with FILESEEK().  If
     the function is called with the <cFile> parameter, it returns the
     attribute of the first entry found.  If no acceptable entry is
     available, a value of 0 is returned.

     When called without a parameter, FILEATTR() returns the attribute for
     the most-recent file located with FILESEEK().  When used with
     FILESEEK(), you can determine the attribute for file groups (wildcards).

     When you call FILEATTR() with the <cFile> parameter, the function
     internally passes 63 (all attributes) as a mask.  When used in
     conjunction with FILESEEK(), you should also designate all 63 as an
     attribute mask, if all files are to be acknowledged.

     Table 7-11:  Coding the File Attribute
     ------------------------------------------------------------------------
     Value   Symb. constants     Assigned attribute
     ------------------------------------------------------------------------
     0       FA_NORMAL
     1       FA_READONLY         READ ONLY (Read-only)
     2       FA_HIDDEN           HIDDEN (Hidden files)
     4       FA_SYSTEM           SYSTEM (System files)
     8       FA_VOLUME           VOLUME (Name of a floppy/hard disk)
     16      FA_DIRECTORY        DIR (Directory)
     32      FA_ARCHIVE          ARCHIVE (Changes since last backup)
     ------------------------------------------------------------------------

     If multiple attributes are implemented for a file, the value of each
     corresponding attribute is added.

 Examples

     .  Show the attribute of a specific file:

        ? FILEATTR("C:\TEXT\TEXT.TXT")      // 32  ARCHIVE

     .  The attribute for an ARCHIVE/HIDDEN file:

        ? FILEATTR("C\HIDE.TXT")            // 34  HIDDEN + ARCHIVE

     .  Used in conjunction with FILESEEK():

        cFile  :=  FILESEEK("C:\TEXT\TEXT.TXT")
        DO WHILE .NOT. EMPTY (cFile)
           ? cFile, FILEATTR()              // Name & file attribute
           cFile  :=  FILESEEK()            // Search for next entry
        ENDDO

See Also: FILESEEK() FILEDATE() FILESIZE() FILETIME()

CT_FILEAPPEND

 FILEAPPEND()
 Appends data to a file

 Syntax

     FILEAPPEND(<cSourceFile>, <cTargetFile>)
        --> nAttachedByte

 Arguments

     <cSourceFile>  Designates the file that is appended to
     <cTargetFile>.

     <cTargetFile>  Designates the file to which <cSource> is appended.
     Drive and path designation are permitted for both files, wildcards are
     not.

 Returns

     FILEAPPEND() returns the number of characters appended on to
     <cTargetFile>.

 Description

     FILEAPPEND() takes fragmented files, split them up on different floppies
     and reassemble them.  This sort of fragmented file could be created with
     the FILECOPY() system described in this chapter.  You only need explicit
     information, such as VOLUME labels, to recognize the different disks.
     If the target file does not exist, it is created with FILEAPPEND().  If
     an error occurs while appending to the target file, the file deletes
     completely to avoid accidental and incorrect results.

     Never append data to file if there is no backup copy.

 Notes

     .  Use SETFCREATE(), if FILEAPPEND() creates a new file and an
        alternative attribute needs to be specified.

     .  Use SETSHARE() to protect a target file from access, if it is
        on a network drive.

 Examples

     Shown below is a simplified program to reassemble a file that is divided
     among several disks by a FILECOPY() backup.

     A catalog contains a list of the disks used during backup in the form of
     volume labels and backup file names.

     Structure of the DISKLIST catalog:

     Table 7-10: DISKLIST File Structure
     ------------------------------------------------------------------------
     Field Name     Field Content
     ------------------------------------------------------------------------
     VolLabel       Back up disk drive and volume label
     BackupName     Back up file name, incl. drive and path
     ------------------------------------------------------------------------

     The data in DISKLIST is created by a FILECOPY() backup:

     USE DISKLIST                                 // Saved volume labels
     cTargetFile  :=  "C:\TARGET.TXT"
     DO WHILE .NOT. EOF()
        IF .NOT. EMPTY(FILESEEK(cVolLabel, 8)     // Correct disk ?
           FILEAPPEND(cBackupName, cTargetFile)   // Yes, append data
           SKIP
        ELSE
           ? "Please insert the correct disk  !"
        ENDIF
     ENDDO

See Also: FILECOPY() FILESEEK() SETSHARE() SETFCREATE() CSETSAFETY()

CT_DRIVETYPE

 DRIVETYPE()
 Determines the drive type

 Syntax

     DRIVETYPE([<cDrive>]) --> nDriveType

 Argument

     <cDrive>   Designates the drive (A, B, C, etc.) for which the type
     is determined.  The default is the current drive.

 Returns

     DRIVETYPE() returns a numeric value for the drive type.  The following
     codes apply:

     Table 7-9:  Drive Type Coding
     ------------------------------------------------------------------------
     Code    Definition
     ------------------------------------------------------------------------
     0       RAM Disk
     1       Floppy Disk (disk change cannot be established by system)
     2       Floppy Disk (disk change can be established by system)
     3       Hard Disk
     ------------------------------------------------------------------------

 Description

     Warning!  Only for AT-class computers.

     This function determines if you are dealing with a floppy drive, a hard
     disk, or a RAM disk.

 Note

     .  Although DRIVETYPE() returns a 0 value for logical DOS
        partitions, RAM floppies, and unavailable drives, you must also
        differentiate with DISKTYPE().  Here, each hard disk partition
        returns a 248 value.  A RAM floppy created with VDISK.SYS behaves
        like a single-sided floppy with eight sectors, which returns a 254
        value.  If there is an unavailable drive, the DISTYPE() returns a
        value of 0.

 Example

     Determine if the drive is a RAM floppy:

     IF DRIVETYPE() == 0 .AND. DISKTYPE() == 254
        ? "Drive " + DISKNAME() + ":  is a RAM-disk!"
     ENDIF

See Also: DISKTYPE() DISKNAME()