Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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. Public Function

writeFile

Public Function
std.tar.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

Params

  • w: *Writer
  • sub_path: []const u8

    Assumed to use / for any path separators.

  • file_reader: *Io.File.Reader
  • mtime: u64

    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.

File

tar/Writer.zig:54
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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);
}