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 standard library.
std › Io › Threaded › dirStatFileWasi Private Function dirStatFileWasi Doc Source Private Function std.Io.Threaded.dirStatFileWasi
fn dirStatFileWasi (
userdata : ?*anyopaque ,
dir : Dir ,
sub_path : []const u8 ,
options : Dir .StatFileOptions ,
) Dir .StatFileError !File .Stat Params userdata : ?*anyopaque dir : Dir sub_path : []const u8 options : Dir .StatFileOptions File Io/Threaded.zig: 3823
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866 fn dirStatFileWasi (
userdata : ?*anyopaque ,
dir : Dir ,
sub_path : []const u8 ,
options : Dir .StatFileOptions ,
) Dir .StatFileError !File .Stat {
if (builtin .link_libc ) return dirStatFilePosix (userdata , dir , sub_path , options );
const t : *Threaded = @ptrCast (@alignCast (userdata ));
_ = t ;
const wasi = std .os .wasi ;
const flags : wasi .lookupflags_t = .{
.SYMLINK_FOLLOW = options .follow_symlinks ,
};
var stat : wasi .filestat_t = undefined ;
const syscall : Syscall = try .start ();
while (true ) {
switch (wasi .path_filestat_get (dir .handle , flags , sub_path .ptr , sub_path .len , &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 ), // File descriptor used after closed.
.NOMEM => return error .SystemResources ,
.ACCES => return error .AccessDenied ,
.FAULT => |err | return errnoBug (err ),
.NAMETOOLONG => return error .NameTooLong ,
.NOENT => return error .FileNotFound ,
.NOTDIR => return error .FileNotFound ,
.NOTCAPABLE => return error .AccessDenied ,
.ILSEQ => return error .BadPathName ,
else => |err | return posix .unexpectedErrno (err ),
}
},
}
}
}