File Properties / Attributes

File Properties / Attributes Functions

FileAttr Determines a file’s attributes
FileDate Determines the file date
FileSize Determines the size of a file
FileTime Determines a file’s time

FileFindXxxx

FileFindXxxx

Searches for files by name and attribute and get file properties

Syntax :

      FileFindFirst( <cFileNameMask>, @<pFFindInfo>[, <nAttr> ] ) -> <lFound>
      FileFindNext(  <pFFindInfo> ) -> <lFound>
      FileFindName(  <pFFindInfo> ) -> <cFileName>
      FileFindAttr(  <pFFindInfo> ) -> <nAttr>
      FileFindSize(  <pFFindInfo> ) -> <nSize>
      FileFindDate(  <pFFindInfo> ) -> <dDate>
      FileFindTime(  <pFFindInfo> ) -> <cTime>

Arguments

<cFileNameMask> : A file name including its path and drive designation. It may contain wildcards.

<pFFindInfo> : A pointer for an internal data structure to hold file(s) info

<nAttr> : The file attribute that corresponds to the ones described in the table on the next page. The default value is 0.

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

Returns

<lFound> : A logical value indicate file existence

<cFileName> : Name of file found by FileFindFirst() or FileFindNext() (without drive/dir)

<nAttr> : A numeric value indicate attribute info of file

<nSize> : A numeric value indicate size of file

<dDate> : A date value indicate date of file

<cTime> : A character value indicate time of file (as “HH:MM:SS”)

Description

FileFindXxxx functions provides a set of info on a set of file.

Calling first FileFindFirst() build an internal data structure ( probably an array like returned by Directory() ). And then calling other FileFindXxxx functions returns individual file info for last file found.

This function set look like FileSeek() function. For more info look at it.

Note

Internal Data Buffer : Every FileFindXxxx() function uses internal data structure <pFFindInfo>. For further using this variable should be passed by reference in FileFindFirst(). May be useful release this buffer by go out of scope or be explicitly release by freeing <pFFindInfo> variable a way like this:

<pFFindInfo> := NIL

Example

      PROC TestFFs()
         LOCAL pFFInfo
         LOCAL nFileNo := 0
         LOCAL lContinue := FileFindFirst( '*.*', @pFFInfo )

         WHIL lContinue
            ? PAD( ++nFileNo, 3),;
              PAD( FileFindName( pFFInfo ), 23 ),;
                   FileFindAttr( pFFInfo ),;
                   FileFindSize( pFFInfo ),;
                   FileFindDate( pFFInfo ),;
                   FileFindTime( pFFInfo )
            lContinue := FileFindNext( pFFInfo )
         END

         RETU // TestFFs()

Seealso

Directory(), FileSeek(), FileAttr(), FileDate(), FileSize(), FileTime(), HB_FileMatch()

FileTime

FileTime

Determines a file’s time

Syntax

      FileTime([<cFileMap>, [<nFileAttr>]]) --> <cFileClockTime>

Arguments

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

<nFileAttr> : Designates the file attribute explained in the table below. The default value is 0.

() : If the function is called without parameters, it returns the file time from the current FileSeek() buffer.

Returns

<cFileClockTime> : the clock time for the <cFileMap>; the clock time from the FileSeek() buffer (when called without parameters), or a null string.

Description

Implement FileTime() alone or in conjunction with FileSeek(). If the function is called with the <cFileMap> parameter, it returns the time of the first entry found. If no matching entry is available, a null string is returned.

When called without parameters, FileTime() returns the clock time of the last file found with FileSeek(). You can also determine the clock time of file groups (wildcards) when the function is used in conjunction with FileSeek().

You can designate the attribute for the desired file in numeric form:

          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)
          16      FA_DIRECTORY        (Subdirectory)
          32      FA_ARCHIVE          ARCHIVE (Changes since last backup)
          ---------------------------------------------------------------

Only the SYSTEM, HIDDEN, VOLUME, or DIR attributes must be specified for an entry to be found. If multiple attributes are implemented simultaneously, the table values are added accordingly. Of course, not all combinations are useful.

Examples

      .  The clock time of a particular file:

         ? FileTime("C:\TEXT\TEXT.TXT")      // File clock time or ""

      .  The clock time of an ARCHIVE/HIDDEN file:

         ? FileTime("C:\HIDE.TXT", 34")      // File clock time or ""

      .  Used in conjunction with FileSeek():

         cFile  :=  FileSeek(C:\TEXT.TXT")
         DO WHILE .NOT. EMPTY(cFile)
            ? cFile, FileTime()              // File name and clock time
            cFile  := FileSeek()             // Search for next entry
         ENDDO

Seealso

FileSeek(), FileAttr(), FileDate(), FileSize()

FileDate

FileDate

Determines the file date

Syntax

      FileDate([<cFileMap>, [<nFileAttr>]]) --> <dFileDate>

Arguments

<cFileMap> : Designates a file name, including its path and drive designation. <nFileAttr> : Designates the file attribute explained in the table below. The default value is 0. () If you call this function without parameters, it returns the file date from the current FileSeek() buffer.

Returns

<dFileDate> : the date of the searched for entry, the date from the FileSeek() buffer (when called without parameters), or an empty date.

Description

You can implement FileDate() alone or in conjunction with FileSeek(). If you use the <cFileMap> parameter to call this function, it returns the date of the first entry found. If a suitable entry is not present, an empty date is returned.

When called without parameters, FileDate() returns the date of the last file it located with FileSeek(). You could also determine the dates for a file group (wildcards), when used it in conjunction with FileSeek().

The attribute for the desired file can be specified in numeric form:

          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)
          16      FA_DIRECTORY        DIR (Directory)
          32      FA_ARCHIVE          ARCHIVE (Changes since last backup)
          ---------------------------------------------------------------

To find a file, specify only the SYSTEM, HIDDEN, VOLUME, or DIR attributes. If multiple attributes are implemented simultaneously, the table values are added accordingly. Of course, not all combinations are useful.

Examples

      .  Show the date of a particular file:

         ? FileDate("C:\TEXT\TEXT.TXT")     // The date

      .  The date of an ARCHIVE/HIDDEN file:

         ? FileDate("C:\HIDE.TXT", 34)      // The date

      .  Used in conjunction with FileSeek():

         cFile  :=  FileSeek("C:\TEXT\*.TXT")
         DO WHILE .NOT. EMPTY(cFile)
            ? cFile, FileDate()             // Name & date of file
            cFile  :=  FileSeek()           // Search for next entry
         ENDDO

Seealso

FileSeek(), FileAttr(), FileSize(), FileTime()

FileAttr

FileAttr

Determines a file’s attributes

Syntax

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

Argument

<cFile> : File name, including the path and drive designation.

Returns

<nFileAttr> : a numeric value for file attributes

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.

          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

Seealso

FileSeek(), FileDate(), FileSize(), FileTime()

SP_FILEINFO

FILEINFO()

  Short:
  ------
  FILEINFO() Returns file date,time,size

  Returns:
  --------
  <expInfo> => Returns file date,time or size

  Syntax:
  -------
  FILEINFO(cFileName,nInfo)

  Description:
  ------------
  Returns info on file in <cFileName> based on param
  passed as <nInfo>

     1  - returns file size (numeric)

     2  - returns file date (date)

     3  - returns file time (character)

  Examples:
  ---------
   nFilesize     := fileinfo("customer.dbf",1)
   dFileDate     := fileinfo("customer.dbf",2)
   dFileTime     := fileinfo("customer.dbf",3)

  Source:
  -------
  S_FILEIN.PRG

 

CT_FILESIZE

 FILESIZE()
 Determines the size of a file
------------------------------------------------------------------------------
 Syntax

     FILESIZE([<cFileMap>, [<FileAttr>]]) --> nFileSize

 Arguments

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

     <FileAttr>  Designates the file attribute that is explained in the
     table below.  The default value is 0.

     ()  If the function is called without parameters, it returns the file
     size from the current FILESEEK() buffer.

 Returns

     FILESIZE() returns the designated file's size, the size from the
     FILESEEK() buffer (when called without a parameter), or -1.

 Description

     Implement FILESIZE() alone or in conjunction with FILESEEK().  If the
     function is called with the <cFileMap> parameter, it returns the size of
     the first entry found.  If no matching entry is available, then a value
     of -1  is returned

     When called without parameters, FILESIZE() returns the size of the most
     recent file found with FILESEEK().  Used in conjunction with FILESEEK(),
     you can also determine the size of file groups (wildcards).

     You can designate the attribute for the desired file in numeric form:

     Table 7-16:  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)
     32      FA_ARCHIVE          ARCHIVE (Changes since last backup.)
     ------------------------------------------------------------------------

     Specify only the SYSTEM, HIDDEN, VOLUME, or DIR attributes for an entry
     to be found.  If multiple attributes are implemented simul-taneously,
     the table values are added accordingly.  Of course, not all combinations
     are useful.

 Examples

     .  Show the size of a particular file:

        ? FILESIZE("C:\TEXT\TEXT.TXT")      // File size or -1

     .  The size of an ARCHIVE/HIDDEN file:

        ? FILESIZE("C:\HIDE.TXT", 34")      // File size or -1

     .  Used in conjunction with FILESEEK():

        cFile  :=  FILESEEK(C:\TEXT.TXT")
        DO WHILE .NOT. EMPTY(cFile)
           ? cFile, FILESIZE()              // File name and size
           cFile  := FILESEEK()             // Search for next entry
        ENDDO

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