Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Io/ › Threaded.zig › fileStatWasi
fileStatWasi
Threaded.fileStatWasi
fn fileStatWasi (userdata : ?*anyopaque , file : File ) File .StatError !File .Stat
File
Code
fn fileStatWasi (userdata : ?*anyopaque , file : File ) File .StatError !File .Stat {
if (builtin .link_libc ) return fileStatPosix (userdata , file );
const t : *Threaded = @ptrCast (@alignCast (userdata ));
_ = t ;
const syscall : Syscall = try .start ();
while (true ) {
var stat : std .os .wasi .filestat_t = undefined ;
switch (std .os .wasi .fd_filestat_get (file .handle , &stat )) {
.SUCCESS => {
syscall .finish ();
return statFromWasi (&stat );
},
.INTR => {
try syscall .checkCancel ();
continue ;
},
else => |e | {
syscall .finish ();
switch (e ) {
.INVAL => |err | return errnoBug (err ),
.BADF => |err | return errnoBug (err ),
.NOMEM => return error .SystemResources ,
.ACCES => return error .AccessDenied ,
.NOTCAPABLE => return error .AccessDenied ,
else => |err | return posix .unexpectedErrno (err ),
}
},
}
}
}