diff options
author | David Symonds <dsymonds@golang.org> | 2009-07-06 22:59:31 -0700 |
---|---|---|
committer | David Symonds <dsymonds@golang.org> | 2009-07-06 22:59:31 -0700 |
commit | ad705cb6a40e1c34c4f7a67a5f1b3703c680c838 (patch) | |
tree | e1137fb5a3fb50ebdaad3cc8ca6599c6fce8786e /src/pkg/archive | |
parent | 91a6358908896cb93c66dbbb25808285cff91e4c (diff) | |
download | golang-ad705cb6a40e1c34c4f7a67a5f1b3703c680c838.tar.gz |
Add support for v7 tar.
R=rsc
APPROVED=rsc
DELTA=32 (26 added, 4 deleted, 2 changed)
OCL=31172
CL=31242
Diffstat (limited to 'src/pkg/archive')
-rw-r--r-- | src/pkg/archive/tar/testdata/v7.tar | bin | 0 -> 3072 bytes | |||
-rw-r--r-- | src/pkg/archive/tar/untar.go | 10 | ||||
-rw-r--r-- | src/pkg/archive/tar/untar_test.go | 23 |
3 files changed, 27 insertions, 6 deletions
diff --git a/src/pkg/archive/tar/testdata/v7.tar b/src/pkg/archive/tar/testdata/v7.tar Binary files differnew file mode 100644 index 000000000..dd33f92ff --- /dev/null +++ b/src/pkg/archive/tar/testdata/v7.tar diff --git a/src/pkg/archive/tar/untar.go b/src/pkg/archive/tar/untar.go index e662971a4..3ebfc5e56 100644 --- a/src/pkg/archive/tar/untar.go +++ b/src/pkg/archive/tar/untar.go @@ -4,7 +4,7 @@ // The tar package implements access to tar archives. // It aims to cover most of the variations, including those produced -// by GNU and BSD tars (not yet started). +// by GNU and BSD tars. // // References: // http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5 @@ -12,8 +12,7 @@ package tar // TODO(dsymonds): -// - Make it seekable. -// - Extensions. +// - pax extensions import ( "bufio"; @@ -211,9 +210,6 @@ func (tr *Reader) readHeader() *Header { hdr := new(Header); s := slicer(header); - // TODO(dsymonds): The format of the header depends on the value of magic (hdr[257:262]), - // so use that value to do the correct parsing below. - hdr.Name = cString(s.next(100)); hdr.Mode = tr.octal(s.next(8)); hdr.Uid = tr.octal(s.next(8)); @@ -225,6 +221,8 @@ func (tr *Reader) readHeader() *Header { hdr.Linkname = cString(s.next(100)); // The remainder of the header depends on the value of magic. + // The original (v7) version of tar had no explicit magic field, + // so its magic bytes, like the rest of the block, are NULs. magic := string(s.next(8)); // contains version field as well. var format string; switch magic { diff --git a/src/pkg/archive/tar/untar_test.go b/src/pkg/archive/tar/untar_test.go index 11f7735f1..9a42c9c92 100644 --- a/src/pkg/archive/tar/untar_test.go +++ b/src/pkg/archive/tar/untar_test.go @@ -79,6 +79,29 @@ var untarTests = []*untarTest{ }, }, }, + &untarTest{ + file: "testdata/v7.tar", + headers: []*Header{ + &Header{ + Name: "small.txt", + Mode: 0640, + Uid: 73025, + Gid: 5000, + Size: 5, + Mtime: 1246508266, + Typeflag: '\x00', + }, + &Header{ + Name: "small2.txt", + Mode: 0640, + Uid: 73025, + Gid: 5000, + Size: 11, + Mtime: 1245217492, + Typeflag: '\x00', + }, + }, + }, }; func TestAll(t *testing.T) { |