Unit 'sysutils' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

FileAge

Return the timestamp of a file.

Declaration

Source position: filutilh.inc line 222

function FileAge(

  const FileName: UnicodeString

):Int64;

function FileAge(

  const FileName: UnicodeString;

  out FileDateTime: TDateTime;

  FollowLink: Boolean = True

):Boolean;

function FileAge(

  const FileName: RawByteString;

  out FileDateTime: TDateTime;

  FollowLink: Boolean = True

):Boolean;

function FileAge(

  const FileName: RawByteString

):Int64;

Description

FileAge in it's simplest form returns the last modification time of file FileName as an opaque os-dependent file timestamp. In this case, the return value can be transformed to a TDateTime value with the FileDateToDateTime function.

In case a FileDateTime argument is supplied, the FileAge function will do the transformation by itself, and the file time will be returned in the FileDateTime argument as a TDateTime value. The function return value is then a boolean indicating success or failure.

The FollowSymlink parameter can be set to False to read the timestamp of a symbolic link, instead of the timestamp of the file the symbolic link points to (which is the default behaviour).

FileAge cannot be used on directories, it will return -1 (or False) if FileName indicates a directory.

Errors

In case of errors, -1 or False is returned.

See also

FileDateToDateTime

  

Convert a FileDate value to a TDateTime value.

FileExists

  

Check whether a particular file exists in the file system.

FileGetAttr

  

Return attributes of a file.

Example

Program Example36;

{ This program demonstrates the FileAge function }

Uses sysutils;

Var S : TDateTime;
    fa : Longint;
Begin
  fa:=FileAge('ex36.pp');
  If Fa<>-1 then
    begin
    S:=FileDateTodateTime(fa);
    Writeln ('I''m from ',DateTimeToStr(S))
    end;
End.

Documentation generated on: Oct 27 2024