Procházet zdrojové kódy

* make statx based Sysutils.FileAge working with relative pathes
+ test

git-svn-id: trunk@48519 -
(cherry picked from commit b08717fef665774b150453e3b2ed979dc851d098)

florian před 4 roky
rodič
revize
43f3819feb
2 změnil soubory, kde provedl 9 přidání a 1 odebrání
  1. 1 1
      rtl/unix/sysutils.pp
  2. 8 0
      tests/test/units/sysutils/tfileage.pp

+ 1 - 1
rtl/unix/sysutils.pp

@@ -574,7 +574,7 @@ begin
 
 {$ifdef USE_STATX}
   { first try statx }
-  if (statx(0,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
+  if (statx(AT_FDCWD,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
     begin
       Result:=Infox.stx_mtime.tv_sec;
       exit;

+ 8 - 0
tests/test/units/sysutils/tfileage.pp

@@ -7,4 +7,12 @@ begin
       writeln('Compilation time and run time differ too much, SysUtils.FileAge buggy?');
       halt(1);
     end;
+
+  { test with relative path }
+  if 3600*24*(now()-FileDateToDateTime(FileAge(ExtractRelativePath(GetCurrentDir+DirectorySeparator,paramstr(0)))))>7200 then
+    begin
+      writeln('FileAge returns: ',FileDateToDateTime(FileAge(paramstr(0))));
+      writeln('Compilation time and run time differ too much, SysUtils.FileAge buggy?');
+      halt(1);
+    end;
 end.