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 › dirStatFileLinux Private Function dirStatFileLinux Doc Source Private Function std.Io.Threaded.dirStatFileLinux
fn dirStatFileLinux (
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: 3710
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756 fn dirStatFileLinux (
userdata : ?*anyopaque ,
dir : Dir ,
sub_path : []const u8 ,
options : Dir .StatFileOptions ,
) Dir .StatFileError !File .Stat {
const t : *Threaded = @ptrCast (@alignCast (userdata ));
_ = t ;
const linux = std .os .linux ;
const sys = if (statx_use_c ) std .c else std .os .linux ;
var path_buffer : [posix .PATH_MAX ]u8 = undefined ;
const sub_path_posix = try pathToPosix (sub_path , &path_buffer );
const flags : u32 = linux .AT .NO_AUTOMOUNT |
@as (u32 , if (!options .follow_symlinks ) linux .AT .SYMLINK_NOFOLLOW else 0 );
const syscall : Syscall = try .start ();
while (true ) {
var statx = std .mem .zeroes (linux .Statx );
switch (sys .errno (sys .statx (dir .handle , sub_path_posix , flags , linux_statx_request , &statx ))) {
.SUCCESS => {
syscall .finish ();
return statFromLinux (&statx );
},
.INTR => {
try syscall .checkCancel ();
continue ;
},
else => |e | {
syscall .finish ();
switch (e ) {
.ACCES => return error .AccessDenied ,
.BADF => |err | return errnoBug (err ), // File descriptor used after closed.
.FAULT => |err | return errnoBug (err ),
.INVAL => |err | return errnoBug (err ),
.LOOP => return error .SymLinkLoop ,
.NAMETOOLONG => |err | return errnoBug (err ), // Handled by pathToPosix() above.
.NOENT => return error .FileNotFound ,
.NOTDIR => return error .NotDir ,
.NOMEM => return error .SystemResources ,
else => |err | return posix .unexpectedErrno (err ),
}
},
}
}
}