Browse Source

+ implemented SysUtils.FileAge for WASI

Nikolay Nikolov 3 years ago
parent
commit
38075ac30c
1 changed files with 15 additions and 0 deletions
  1. 15 0
      rtl/wasi/sysutils.pp

+ 15 - 0
rtl/wasi/sysutils.pp

@@ -404,7 +404,22 @@ end;
 
 
 Function FileAge (Const FileName : RawByteString): Int64;
+var
+  res: __wasi_errno_t;
+  pr: RawByteString;
+  fd: __wasi_fd_t;
+  Info: __wasi_filestat_t;
 begin
+  if not ConvertToFdRelativePath(FileName,fd,pr) then
+    begin
+      result:=-1;
+      exit;
+    end;
+  res:=__wasi_path_filestat_get(fd,0,PChar(pr),length(pr),@Info);
+  if res=__WASI_ERRNO_SUCCESS then
+    result:=Info.mtim div 1000000000
+  else
+    result:=-1;
 end;