| ... | ... | @@ -1,4 +1,21 @@ |
| 1 | 1 | const 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 | |
| 2 | 19 | const assert = std.debug.assert; |
| 3 | 20 | |
| 4 | 21 | pub const Options = struct { |
| ... | ... | @@ -193,7 +210,7 @@ pub const Header = struct { |
| 193 | 210 | } |
| 194 | 211 | }; |
| 195 | 212 | |
| 196 | | // Breaks string on first null char. |
| 213 | // Breaks string on first null character. |
| 197 | 214 | fn nullStr(str: []const u8) []const u8 { |
| 198 | 215 | for (str, 0..) |c, i| { |
| 199 | 216 | if (c == 0) return str[0..i]; |