From 58e0e509c6dc8fae77e668ef8ee267dfdb619196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Anic=CC=81?= Date: Wed, 6 Dec 2023 15:35:29 +0100 Subject: [PATCH] tar: add module comment and references --- lib/std/tar.zig | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/std/tar.zig b/lib/std/tar.zig index 6d1934d91c..a5eb7a3ef5 100644 --- a/lib/std/tar.zig +++ b/lib/std/tar.zig @@ -1,4 +1,21 @@ const std = @import("std.zig"); +/// Tar archive is single ordinary file which can contain many files (or +/// directories, symlinks, ...). It's build by series of blocks each size of 512 +/// bytes. First block of each entry is header which defines type, name, size +/// permissions and other attributes. Header is followed by series of blocks of +/// file content, if any that entry has content. Content is padded to the block +/// size, so next header always starts at block boundary. +/// +/// This simple format is extended by GNU and POSIX pax extensions to support +/// file names longer than 256 bytes and additional attributes. +/// +/// This is not comprehensive tar parser. Here we are only file types needed to +/// support Zig package manager; normal file, directory, symbolic link. And +/// subset of attributes: name, size, permissions. +/// +/// GNU tar reference: https://www.gnu.org/software/tar/manual/html_node/Standard.html +/// pax reference: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13 + const assert = std.debug.assert; pub const Options = struct { @@ -193,7 +210,7 @@ pub const Header = struct { } }; -// Breaks string on first null char. +// Breaks string on first null character. fn nullStr(str: []const u8) []const u8 { for (str, 0..) |c, i| { if (c == 0) return str[0..i];