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 › Uring › fileLength Private Function fileLength Doc Source Private Function std.Io.Uring.fileLength
fn fileLength (userdata : ?*anyopaque , file : File ) File .LengthError !u64 Params userdata : ?*anyopaque file : File File Io/Uring.zig: 3590
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632 fn fileLength (userdata : ?*anyopaque , file : File ) File .LengthError !u64 {
const ev : *Evented = @ptrCast (@alignCast (userdata ));
var cancel_region : CancelRegion = .init ();
defer cancel_region .deinit ();
while (true ) {
var statx_buf = std .mem .zeroes (linux .Statx );
const thread = try cancel_region .awaitIoUring ();
thread .enqueue ().* = .{
.opcode = .STATX ,
.flags = 0 ,
.ioprio = 0 ,
.fd = file .handle ,
.off = @intFromPtr (&statx_buf ),
.addr = @intFromPtr ("" ),
.len = @bitCast (linux .STATX { .SIZE = true }),
.rw_flags = linux .AT .EMPTY_PATH ,
.user_data = @intFromPtr (cancel_region .fiber ),
.buf_index = 0 ,
.personality = 0 ,
.splice_fd_in = 0 ,
.addr3 = 0 ,
.resv = 0 ,
};
ev .yield (null , .nothing );
switch (cancel_region .errno ()) {
.SUCCESS => {
if (!statx_buf .mask .SIZE ) return error .Unexpected ;
return statx_buf .size ;
},
.INTR , .CANCELED => {},
.ACCES => |err | return errnoBug (err ),
.BADF => |err | return errnoBug (err ), // File descriptor used after closed.
.FAULT => |err | return errnoBug (err ),
.INVAL => |err | return errnoBug (err ),
.LOOP => |err | return errnoBug (err ),
.NAMETOOLONG => |err | return errnoBug (err ),
.NOENT => |err | return errnoBug (err ),
.NOMEM => return error .SystemResources ,
.NOTDIR => |err | return errnoBug (err ),
else => |err | return unexpectedErrno (err ),
}
}
}