authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2023-12-06 15:35:29+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-13 19:37:33-07:00
log58e0e509c6dc8fae77e668ef8ee267dfdb619196
tree20526d493e725e474005cfaef2ed21b19d9637ba
parenta3cf8ec71ec17f384608a6df0d41b804f2cfe231

tar: add module comment and references


1 files changed, 18 insertions(+), 1 deletions(-)

lib/std/tar.zig+18-1
......@@ -1,4 +1,21 @@
11const std = @import("std.zig");
2/// Tar archive is single ordinary file which can contain many files (or
3/// directories, symlinks, ...). It's build by series of blocks each size of 512
4/// bytes. First block of each entry is header which defines type, name, size
5/// permissions and other attributes. Header is followed by series of blocks of
6/// file content, if any that entry has content. Content is padded to the block
7/// size, so next header always starts at block boundary.
8///
9/// This simple format is extended by GNU and POSIX pax extensions to support
10/// file names longer than 256 bytes and additional attributes.
11///
12/// This is not comprehensive tar parser. Here we are only file types needed to
13/// support Zig package manager; normal file, directory, symbolic link. And
14/// subset of attributes: name, size, permissions.
15///
16/// GNU tar reference: https://www.gnu.org/software/tar/manual/html_node/Standard.html
17/// pax reference: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13
18
219const assert = std.debug.assert;
320
421pub const Options = struct {
......@@ -193,7 +210,7 @@ pub const Header = struct {
193210 }
194211};
195212
196// Breaks string on first null char.
213// Breaks string on first null character.
197214fn nullStr(str: []const u8) []const u8 {
198215 for (str, 0..) |c, i| {
199216 if (c == 0) return str[0..i];