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.

setPath

Writes path in posix header, if don't fit (in name+prefix; 100+155 bytes) writes it in gnu extended header.

Writer.setPath
fn setPath(w: *Writer, header: *Header, sub_path: []const u8) Error!void

File

lib/std/tar/Writer.zig:135

Code

fn setPath(w: *Writer, header: *Header, sub_path: []const u8) Error!void {
    header.setPath(w.prefix, sub_path) catch |err| switch (err) {
        error.NameTooLong => {
            // write extended header
            const buffers: []const []const u8 = if (w.prefix.len == 0)
                &.{sub_path}
            else
                &.{ w.prefix, "/", sub_path };
            try w.writeExtendedHeader(.gnu_long_name, buffers);
        },
        else => |e| return e,
    };
}