Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Created April 28, 2014 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpluimers/11366076 to your computer and use it in GitHub Desktop.
Save jpluimers/11366076 to your computer and use it in GitHub Desktop.
A small Delphi example is about SysUtils.FileAge. It has two overloads, of which one is deprecated. So the first call will give you a compiler warning.
program DeprecatedFileAge;
uses
SysUtils;
{$APPTYPE CONSOLE}
var
ExeName: string;
IntegerAge: Integer;
DateTimeAge: TDateTime;
begin
ExeName := ParamStr(0);
if FileExists(ExeName) then // [Pascal Warning] DeprecatedFileAge.dpr(17): W1000 Symbol 'FileAge' is deprecated
begin
IntegerAge := FileAge(ExeName);
DateTimeAge := FileDateToDateTime(IntegerAge);
Writeln(Format('Age of "%s" is "%s"', [ExeName, DateTimeToStr(DateTimeAge)]));
end;
if FileAge(ExeName, DateTimeAge) then
begin
Writeln(Format('Age of "%s" is "%s"', [ExeName, DateTimeToStr(DateTimeAge)]));
end;
(*
In de SysUtils unit:
{ FileAge returns the date-and-time stamp of the specified file. The return
value can be converted to a TDateTime value using the FileDateToDateTime
function. The return value is -1 if the file does not exist. This version
does not support date-and-time stamps prior to 1980 and after 2107. }
function FileAge(const FileName: string): Integer; overload; deprecated;
{ FileAge retrieves the date-and-time stamp of the specified file as a
TDateTime. This version supports all valid NTFS date-and-time stamps
and returns a boolean value that indicates whether the specified
file exists. }
{$IFDEF MSWINDOWS}
function FileAge(const FileName: string; out FileDateTime: TDateTime): Boolean; overload;
{$ENDIF}
*)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment