1
0
mirror of https://github.com/golang/go synced 2024-11-08 05:56:12 -07:00
go/src/archive/tar
Joe Tsai 9d3d370632 archive/tar: support reporting and selecting the format
The Reader and Writer are now at feature parity,
meaning that everything that can be parsed by the Reader,
can also be composed by the Writer.

This position enables us to support selection of the format
in a backwards compatible way, since it ensures that everything
that can be read can also be round-trip written.

As such, we add the following new API:
    type Format int
            const FormatUnknown Format = 0 ...
    type Header struct { ...; Format Format }

The new Header.Format field is populated by the Reader on the
best guess on what the format is. Note that the Reader is very liberal
in what it permits, so a hybrid TAR file using aspects of multiple
formats can still be decoded, but will be reported as FormatUnknown.

Even though Reader has full support for V7 and basic support for STAR,
it will still report those formats as unknown (and the constants for
those formats are not even exported). The reasons for this is because
the Writer has no support for V7 or STAR. Leaving it as unknown allows
the Writer to choose a format usually USTAR or GNU that can encode
the equivalent Header.

When writing, the Header.allowedFormats will take the Format field
into consideration if it is a known format.

Fixes #18710

Change-Id: I00980c475d067c6969d3414e1ff0224fdd89cd49
Reviewed-on: https://go-review.googlesource.com/58230
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-24 01:35:39 +00:00
..
testdata archive/tar: support reporting and selecting the format 2017-08-24 01:35:39 +00:00
common.go archive/tar: support reporting and selecting the format 2017-08-24 01:35:39 +00:00
example_test.go archive/tar: implement Writer support for sparse files 2017-08-23 22:38:45 +00:00
format.go archive/tar: support reporting and selecting the format 2017-08-24 01:35:39 +00:00
reader_test.go archive/tar: support reporting and selecting the format 2017-08-24 01:35:39 +00:00
reader.go archive/tar: support reporting and selecting the format 2017-08-24 01:35:39 +00:00
stat_atim.go
stat_atimespec.go
stat_unix.go
strconv_test.go archive/tar: support PAX subsecond resolution times 2017-08-15 02:20:22 +00:00
strconv.go archive/tar: add support for long binary strings in GNU format 2017-08-16 00:39:32 +00:00
tar_test.go archive/tar: support reporting and selecting the format 2017-08-24 01:35:39 +00:00
writer_test.go archive/tar: support reporting and selecting the format 2017-08-24 01:35:39 +00:00
writer.go archive/tar: support reporting and selecting the format 2017-08-24 01:35:39 +00:00