Browse Source

+ implemented SysUtils.RenameFile for WASI

Nikolay Nikolov 3 years ago
parent
commit
05c6937fd9
1 changed files with 10 additions and 0 deletions
  1. 10 0
      rtl/wasi/sysutils.pp

+ 10 - 0
rtl/wasi/sysutils.pp

@@ -353,7 +353,17 @@ end;
 
 
 
 
 Function RenameFile (Const OldName, NewName : RawByteString) : Boolean;
 Function RenameFile (Const OldName, NewName : RawByteString) : Boolean;
+var
+  fd1,fd2: __wasi_fd_t;
+  pr1,pr2: RawByteString;
+  res: __wasi_errno_t;
 begin
 begin
+  result:=false;
+  if not ConvertToFdRelativePath(OldName,fd1,pr1) then
+    exit;
+  if not ConvertToFdRelativePath(NewName,fd2,pr2) then
+    exit;
+  result:=__wasi_path_rename(fd1,PChar(pr1),Length(pr1),fd2,PChar(pr2),Length(pr2))=__WASI_ERRNO_SUCCESS;
 end;
 end;