+ implemented dos.SetFTime for WASI

This commit is contained in:
Nikolay Nikolov 2021-10-12 11:06:16 +03:00
parent c4d7773c0e
commit a55980bfb8

View File

@ -799,38 +799,23 @@ Begin
End; End;
Procedure setftime(var f; time : longint); Procedure setftime(var f; time : longint);
(*
Var Var
utim: utimbuf;
DT: DateTime; DT: DateTime;
p : pchar; modtime: UInt64;
{$ifndef FPC_ANSI_TEXTFILEREC} pr: RawByteString;
r : Rawbytestring; fd: __wasi_fd_t;
{$endif not FPC_ANSI_TEXTFILEREC}*)
Begin Begin
(* doserror:=0; doserror:=0;
with utim do UnPackTime(Time,DT);
modtime:=DTToWasiDate(DT);
if ConvertToFdRelativePath(textrec(f).name,fd,pr)<>0 then
begin begin
actime:=fptime;
UnPackTime(Time,DT);
modtime:=DTToUnixDate(DT);
end;
{$ifdef FPC_ANSI_TEXTFILEREC}
{ encoding is already correct }
p:=@textrec(f).name;
{$else}
r:=ToSingleByteFileSystemEncodedFileName(textrec(f).name);
p:=pchar(r);
{$endif}
{ use the pchar rather than the rawbytestring version so that we don't check
a second time whether the string needs to be converted to the right code
page
}
if fputime(p,@utim)<0 then
begin
Time:=0;
doserror:=3; doserror:=3;
end;*) exit;
end;
if __wasi_path_filestat_set_times(fd,0,PChar(pr),length(pr),0,modtime,
__WASI_FSTFLAGS_MTIM or __WASI_FSTFLAGS_ATIM_NOW)<>__WASI_ERRNO_SUCCESS then
doserror:=3;
End; End;
{****************************************************************************** {******************************************************************************