xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

FileStats()

Retrieves file information for a single file.

Syntax

FileStats( <cFileName>    , ;
          [@<cFileAttr>]  , ;
          [@<nFileSize>]  , ;
          [@<dCreateDate>], ;
          [@<nCreateTime>], ;
          [@<dChangeDate>], ;
          [@<nChangeTime>]  ) --> lSuccess

Arguments

<cFileName>
This is a character string holding the name of the file to query. It must include path and file extension. If the path is omitted from <cFileName>, the file is searched in the current directory.
@<cFileAttr>
If specified, <cFileAttr> must be passed by reference. It receives the file attributes of the file as a character string.
@<nFileSize>
If specified, <cFileSize> must be passed by reference. It receives the file size of the file as a numeric value.
@<dCreateDate>
If specified, <dCreateDate> must be passed by reference. It receives the creation date of the file as a date value.
@<nCreateTime>
If specified, <nCreateTime> must be passed by reference. It receives the creation time of the file as a numeric value. The unit is "seconds elapsed since midnight". Use function TString() to convert this value to a "hh:mm:ss" formatted time string.
@<dChangeDate>
If specified, <dChangeDate> must be passed by reference. It receives the last change date of the file as a date value.
@<nChangeTime>
If specified, <nChangeTime> must be passed by reference. It receives the creation time of the file as a numeric value. The unit is "seconds elapsed since midnight".

Return

The return value is .T. (true) when the information on the file <cFileName> could be retrieved, otherwise .F. (false) is returned.

Description

Function FileStats() retrieves statistical information about a single file. It is more efficient than the Directory() function which retrieves the same information for a group of files and stores them in an array. FileStats(), in contrast, allows for "picking" desired information about a single file by passing the according parameters by reference to the function.

Info

See also:Directory(), FCreate(), HB_FSize()
Category: File functions , Low level file functions , xHarbour extensions
Source:rtl\filestat.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows how to retrieve statistical information about
// a single file, and how to convert the time values from Seconds
// to a hh:mm:ss time formatted string.

   PROCEDURE Main
      LOCAL cFileName := "FILESTATS.PRG"
      LOCAL cFileAttr  , nFileSize
      LOCAL dCreateDate, nCreateTime
      LOCAL dChangeDate, nChangeTime

      ? FileStats( cFileName, @cFileAttr  , @nFileSize  , ;
                              @dCreateDate, @nCreateTime, ;
                              @dChangeDate, @nChangeTime  )

      ? "File statistiscs"
      ? "File Name :", cFileName
      ? "Attributes:", cFileAttr
      ? "File Size :", nFileSize
      ? "Created   :", dCreateDate, TString( nCreateTime )
      ? "Changed   :", dChangeDate, TSTring( nChangeTime )
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe