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 › Dispatch › dirAccess Private Function dirAccess Doc Source Private Function std.Io.Dispatch.dirAccess
fn dirAccess (
userdata : ?*anyopaque ,
dir : Dir ,
sub_path : []const u8 ,
options : Dir .AccessOptions ,
) Dir .AccessError !void Params userdata : ?*anyopaque dir : Dir sub_path : []const u8 options : Dir .AccessOptions File Io/Dispatch.zig: 2431
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468 fn dirAccess (
userdata : ?*anyopaque ,
dir : Dir ,
sub_path : []const u8 ,
options : Dir .AccessOptions ,
) Dir .AccessError !void {
const ev : *Evented = @ptrCast (@alignCast (userdata ));
_ = ev ;
var path_buffer : [c .PATH_MAX ]u8 = undefined ;
const sub_path_posix = try pathToPosix (sub_path , &path_buffer );
const flags : u32 = if (options .follow_symlinks ) 0 else c .AT .SYMLINK_NOFOLLOW ;
const mode : u32 =
@as (u32 , if (options .read ) c .R_OK else 0 ) |
@as (u32 , if (options .write ) c .W_OK else 0 ) |
@as (u32 , if (options .execute ) c .X_OK else 0 );
while (true ) switch (c .errno (c .faccessat (dir .handle , sub_path_posix , mode , flags ))) {
.SUCCESS => return ,
.INTR => {},
.ACCES => return error .AccessDenied ,
.PERM => return error .PermissionDenied ,
.ROFS => return error .ReadOnlyFileSystem ,
.LOOP => return error .SymLinkLoop ,
.TXTBSY => return error .FileBusy ,
.NOTDIR => return error .FileNotFound ,
.NOENT => return error .FileNotFound ,
.NAMETOOLONG => return error .NameTooLong ,
.INVAL => |err | return errnoBug (err ),
.FAULT => |err | return errnoBug (err ),
.IO => return error .InputOutput ,
.NOMEM => return error .SystemResources ,
.ILSEQ => return error .BadPathName ,
else => |err | return unexpectedErrno (err ),
};
}