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.

writeFile

Writer.writeFile
pub fn writeFile(
    w: *Writer,
    /// Assumed to use `/` for any path separators.
    sub_path: []const u8,
    file_reader: *Io.File.Reader,
    /// If you want to match the file format's expectations, it wants number of
    /// seconds since POSIX epoch. Zero is also a great option here to make
    /// generated tarballs more reproducible.
    mtime: u64,
) WriteFileError!void

File

lib/std/tar/Writer.zig:54

Code

pub fn writeFile(
    w: *Writer,
    /// Assumed to use `/` for any path separators.
    sub_path: []const u8,
    file_reader: *Io.File.Reader,
    /// If you want to match the file format's expectations, it wants number of
    /// seconds since POSIX epoch. Zero is also a great option here to make
    /// generated tarballs more reproducible.
    mtime: u64,
) WriteFileError!void {
    const size = try file_reader.getSize();

    var header: Header = .{};
    try w.setPath(&header, sub_path);
    try header.setSize(size);
    try header.setMtime(mtime);
    try header.updateChecksum();

    try w.underlying_writer.writeAll(@ptrCast((&header)[0..1]));
    _ = try w.underlying_writer.sendFileAll(file_reader, .unlimited);
    try w.writePadding64(size);
}