mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 04:09:15 +02:00
+ implemented SysUtils.FileExists for WASI
This commit is contained in:
parent
fe903f2ae4
commit
4dc0c37678
@ -431,7 +431,24 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
function FileExists (const FileName: RawByteString; FollowLink : Boolean): boolean;
|
function FileExists (const FileName: RawByteString; FollowLink : Boolean): boolean;
|
||||||
|
var
|
||||||
|
pr: RawByteString;
|
||||||
|
fd: __wasi_fd_t;
|
||||||
|
Info: __wasi_filestat_t;
|
||||||
|
flags: __wasi_lookupflags_t;
|
||||||
begin
|
begin
|
||||||
|
if FileName='' then
|
||||||
|
exit(false);
|
||||||
|
if not ConvertToFdRelativePath(FileName,fd,pr) then
|
||||||
|
exit(false);
|
||||||
|
if FollowLink then
|
||||||
|
flags:=__WASI_LOOKUPFLAGS_SYMLINK_FOLLOW
|
||||||
|
else
|
||||||
|
flags:=0;
|
||||||
|
if __wasi_path_filestat_get(fd,flags,PChar(pr),length(pr),@Info)=__WASI_ERRNO_SUCCESS then
|
||||||
|
result:=Info.filetype<>__WASI_FILETYPE_DIRECTORY
|
||||||
|
else
|
||||||
|
result:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user