# tar: improve diagnostic reporting · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/7d3a31872eda55438259b54818baaa90b6ecd74c)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 7d3a31872eda55438259b54818baaa90b6ecd74c

Requested commit: 7d3a31872eda55438259b54818baaa90b6ecd74c

Commit: 7d3a31872eda55438259b54818baaa90b6ecd74c

Tree: 0f37119cde4ccd495925d05ca70a7b939c252f16

Author: Igor Anić

Committer: Andrew Kelley

## Message

````
tar: improve diagnostic reporting

Using Python testtar file (mentioned in #14310) to test diagnostic
reporting.
Added computing checksum by using both unsigned and signed header bytes
values.
Added skipping gnu exteneded sparse headers while reporting unsupported
header in diagnostic.

Note on testing:

wget https://github.com/python/cpython/raw/3.11/Lib/test/testtar.tar -O
/tmp/testtar.tar

```
test "Python testtar.tar file" {
    const file_name = "testtar.tar";

    var file = try std.fs.cwd().openFile("/tmp/" ++ file_name, .{});
    defer file.close();

    var diag = Options.Diagnostics{ .allocator = std.testing.allocator };
    defer diag.deinit();

    var iter = iterator(file.reader(), &diag);
    while (try iter.next()) |f| {
        std.debug.print("supported: {} {s} {d}\n", .{ f.kind, f.name, f.size });
        try f.skip();
    }
    for (diag.errors.items) |e| {
        switch (e) {
            .unsupported_file_type => |u| {
                std.debug.print("unsupported: {} {s}\n", .{ u.file_type, u.file_name });
            },
            else => unreachable,
        }
    }
}
```

````

## Parents

- [7923a53996f8d24ad27823db3a45a6dd4a2bf317](https://git.cafe/gitcafe/zig/commit/7923a53996f8d24ad27823db3a45a6dd4a2bf317?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/7d3a31872eda55438259b54818baaa90b6ecd74c?format=markdown)
