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 › filePathKind
filePathKind
Threaded.filePathKind
fn filePathKind (t : *Threaded , dir : Dir , sub_path : []const u8 ) !File .Kind
File
Code
fn filePathKind (t : *Threaded , dir : Dir , sub_path : []const u8 ) !File .Kind {
if (native_os == .linux ) {
var path_buffer : [posix .PATH_MAX ]u8 = undefined ;
const sub_path_posix = try pathToPosix (sub_path , &path_buffer );
const linux = std .os .linux ;
const syscall : Syscall = try .start ();
while (true ) {
var statx = std .mem .zeroes (linux .Statx );
switch (linux .errno (linux .statx (
dir .handle ,
sub_path_posix ,
linux .AT .NO_AUTOMOUNT | linux .AT .SYMLINK_NOFOLLOW ,
.{ .TYPE = true },
&statx ,
))) {
.SUCCESS => {
syscall .finish ();
if (!statx .mask .TYPE ) return error .Unexpected ;
return statxKind (statx .mode );
},
.INTR => {
try syscall .checkCancel ();
continue ;
},
.NOMEM => return syscall .fail (error .SystemResources ),
else => |err | return syscall .unexpectedErrno (err ),
}
}
}
const stat = try dirStatFile (t , dir , sub_path , .{ .follow_symlinks = false });
return stat .kind ;
}