Created
April 28, 2014 08:57
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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