Browse Source

+ also implemented FileSetDate(FileName) for WASI, via the __wasi_path_filestat_set_times API call

Nikolay Nikolov 3 years ago
parent
commit
068f781c7a
1 changed files with 19 additions and 0 deletions
  1. 19 0
      rtl/wasi/sysutils.pp

+ 19 - 0
rtl/wasi/sysutils.pp

@@ -28,6 +28,7 @@ interface
 uses
   wasiapi;
 
+{$DEFINE OS_FILESETDATEBYNAME}
 {$DEFINE HAS_SLEEP}
 {$DEFINE HAS_GETTICKCOUNT64}
 
@@ -481,6 +482,24 @@ begin
 end;
 
 
+Function FileSetDate (Const FileName : RawByteString; Age : Int64) : Longint;
+var
+  pr: RawByteString;
+  fd: __wasi_fd_t;
+begin
+  if not ConvertToFdRelativePath(FileName,fd,pr) then
+    begin
+      result:=-1;
+      exit;
+    end;
+  if __wasi_path_filestat_set_times(fd,0,PChar(pr),length(pr),Age*1000000000,Age*1000000000,
+     __WASI_FSTFLAGS_MTIM or __WASI_FSTFLAGS_ATIM)=__WASI_ERRNO_SUCCESS then
+    result:=0
+  else
+    result:=-1;
+end;
+
+
 Function FileGetAttr (Const FileName : RawByteString) : Longint;
 begin
 end;