Browse Source

* Implemented overloaded variant of fileage function

git-svn-id: trunk@21867 -
michael 13 years ago
parent
commit
789a6452c9
2 changed files with 21 additions and 1 deletions
  1. 1 1
      rtl/objpas/sysutils/filutilh.inc
  2. 20 0
      rtl/objpas/sysutils/sysutils.inc

+ 1 - 1
rtl/objpas/sysutils/filutilh.inc

@@ -111,4 +111,4 @@ Function FileIsReadOnly(const FileName: String): Boolean;
 
 Function GetFileHandle(var f : File):THandle;
 Function GetFileHandle(var f : Text):THandle;
-
+function FileAge(const FileName: string; out FileDateTime: TDateTime; FollowLink: Boolean = True): Boolean;

+ 20 - 0
rtl/objpas/sysutils/sysutils.inc

@@ -155,6 +155,25 @@
         temp.free;
       end;
 
+   function FileAge(const FileName: string; out FileDateTime: TDateTime; FollowLink: Boolean = True): Boolean;
+   
+   Var
+     Info : TSearchRec;
+     A : Integer;
+      
+   begin
+     for A:=1 to Length(FileName) do
+       If (FileName[A] in ['?','*']) then
+         Exit(False);
+     A:=0;
+     if Not FollowLink then
+       A:=A or faSymLink;
+     Result:=FindFirst(FileName,A,Info)=0;
+     If Result then 
+       FileDateTime:=FileDatetoDateTime (Info.Time);
+     FindClose(Info);
+   end;
+
   { Interfaces support }
   {$i sysuintf.inc}
 
@@ -761,3 +780,4 @@ begin
   If Assigned(OnBeep) then
     OnBeep;
 end;
+