mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 19:09:16 +02:00
+ implemented DOS.GetFAttr for WASI
This commit is contained in:
parent
4e605fb764
commit
ca242e9ad0
@ -696,42 +696,27 @@ Begin
|
|||||||
End;
|
End;
|
||||||
|
|
||||||
Procedure GetFAttr(var f; var attr : word);
|
Procedure GetFAttr(var f; var attr : word);
|
||||||
(*Var
|
Var
|
||||||
info : baseunix.stat;
|
pr: RawByteString;
|
||||||
LinAttr : longint;
|
fd: __wasi_fd_t;
|
||||||
p : pchar;
|
Info: __wasi_filestat_t;
|
||||||
{$ifndef FPC_ANSI_TEXTFILEREC}
|
|
||||||
r : RawByteString;
|
|
||||||
{$endif not FPC_ANSI_TEXTFILEREC}*)
|
|
||||||
Begin
|
Begin
|
||||||
(* DosError:=0;
|
DosError:=0;
|
||||||
{$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 FPStat(p,info)<0 then
|
|
||||||
begin
|
|
||||||
Attr:=0;
|
Attr:=0;
|
||||||
|
if ConvertToFdRelativePath(textrec(f).name,fd,pr)<>0 then
|
||||||
|
begin
|
||||||
DosError:=3;
|
DosError:=3;
|
||||||
exit;
|
exit;
|
||||||
end
|
end;
|
||||||
else
|
if __wasi_path_filestat_get(fd,__WASI_LOOKUPFLAGS_SYMLINK_FOLLOW,PChar(pr),length(pr),@Info)<>__WASI_ERRNO_SUCCESS then
|
||||||
LinAttr:=Info.st_Mode;
|
begin
|
||||||
if fpS_ISDIR(LinAttr) then
|
DosError:=3;
|
||||||
Attr:=$10
|
exit;
|
||||||
else
|
end;
|
||||||
Attr:=$0;
|
if Info.filetype=__WASI_FILETYPE_DIRECTORY then
|
||||||
if fpAccess(p,W_OK)<0 then
|
Attr:=$10;
|
||||||
Attr:=Attr or $1;
|
|
||||||
if filerec(f).name[0]='.' then
|
if filerec(f).name[0]='.' then
|
||||||
Attr:=Attr or $2;*)
|
Attr:=Attr or $2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure getftime (var f; var time : longint);
|
Procedure getftime (var f; var time : longint);
|
||||||
|
Loading…
Reference in New Issue
Block a user