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 › fileSetLength Private Function fileSetLength Doc Source Private Function std.Io.Uring.fileSetLength
fn fileSetLength (userdata : ?*anyopaque , file : File , length : u64 ) File .SetLengthError !void Params userdata : ?*anyopaque file : File length : u64 File Io/Uring.zig: 3835
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
3867
3868
3869
3870 fn fileSetLength (userdata : ?*anyopaque , file : File , length : u64 ) File .SetLengthError !void {
const ev : *Evented = @ptrCast (@alignCast (userdata ));
var cancel_region : CancelRegion = .init ();
defer cancel_region .deinit ();
while (true ) {
const thread = try cancel_region .awaitIoUring ();
thread .enqueue ().* = .{
.opcode = .FTRUNCATE ,
.flags = 0 ,
.ioprio = 0 ,
.fd = file .handle ,
.off = length ,
.addr = 0 ,
.len = 0 ,
.rw_flags = 0 ,
.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 => return ,
.INTR , .CANCELED => {},
.FBIG => return error .FileTooBig ,
.IO => return error .InputOutput ,
.PERM => return error .PermissionDenied ,
.TXTBSY => return error .FileBusy ,
.BADF => |err | return errnoBug (err ), // Handle not open for writing.
.INVAL => return error .NonResizable , // This is returned for /dev/null for example.
else => |err | return unexpectedErrno (err ),
}
}
}