mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 20:59:42 +02:00
+ implemented SysUtils.FileRead for WASI
This commit is contained in:
parent
305393a9c1
commit
977b2f2a4b
@ -201,7 +201,20 @@ end;
|
||||
|
||||
|
||||
Function FileRead (Handle : THandle; Out Buffer; Count : longint) : Longint;
|
||||
var
|
||||
our_iov: __wasi_iovec_t;
|
||||
our_nread: __wasi_size_t;
|
||||
res: __wasi_errno_t;
|
||||
begin
|
||||
repeat
|
||||
our_iov.buf:=@Buffer;
|
||||
our_iov.buf_len:=Count;
|
||||
res:=__wasi_fd_read(Handle,@our_iov,1,@our_nread);
|
||||
until (res=__WASI_ERRNO_SUCCESS) or ((res<>__WASI_ERRNO_INTR) and (res<>__WASI_ERRNO_AGAIN));
|
||||
if res=__WASI_ERRNO_SUCCESS then
|
||||
Result:=our_nread
|
||||
else
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user