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/ › Dispatch.zig › fileSetLength
fileSetLength
Dispatch.fileSetLength
fn fileSetLength (userdata : ?*anyopaque , file : File , length : u64 ) File .SetLengthError !void
File
Code
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 ;
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 ),
.INVAL => return error .NonResizable ,
else => |err | return unexpectedErrno (err ),
};
}