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 › fileSetLength Private Function fileSetLength Doc Source Private Function std.Io.Dispatch.fileSetLength
fn fileSetLength (userdata : ?*anyopaque , file : File , length : u64 ) File .SetLengthError !void Params userdata : ?*anyopaque file : File length : u64 File Io/Dispatch.zig: 3618
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636 fn fileSetLength (userdata : ?*anyopaque , file : File , length : u64 ) File .SetLengthError !void {
const ev : *Evented = @ptrCast (@alignCast (userdata ));
_ = ev ;
const signed_len : i64 = @bitCast (length );
if (signed_len < 0 ) return error .FileTooBig ; // Avoid ambiguous EINVAL errors.
while (true ) switch (c .errno (c .ftruncate (file .handle , signed_len ))) {
.SUCCESS => return ,
.INTR => {},
.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 ),
};
}