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.

end

Flushes any buffered data and sets the end position of the file.

If not overwriting existing contents, then calling interface.flush directly is sufficient.

Flush failure is handled by setting err so that it can be handled along with other write failures.

Writer.end
pub fn end(w: *Writer) EndError!void

File

lib/std/Io/File/Writer.zig:237

Code

pub fn end(w: *Writer) EndError!void {
    const io = w.io;
    try w.interface.flush();
    switch (w.mode) {
        .positional,
        .positional_simple,
        => w.file.setLength(io, w.pos) catch |err| switch (err) {
            error.NonResizable => return,
            else => |e| return e,
        },

        .streaming,
        .streaming_simple,
        .failure,
        => {},
    }
}