1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // The tar package implements access to tar archives.
6 // It aims to cover most of the variations, including those produced
7 // by GNU and BSD tars.
10 // http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5
11 // http://www.gnu.org/software/tar/manual/html_node/Standard.html
28 TypeXGlobalHeader
= 'g'
31 // A Header represents a single header in a tar archive.
32 // Some fields may not be populated.
50 var zeroBlock
= make([]byte, blockSize
)
52 // POSIX specifies a sum of the unsigned byte values, but the Sun tar uses signed byte values.
53 // We compute and return both.
54 func checksum(header
[]byte) (unsigned
int64, signed
int64) {
55 for i
:= 0; i
< len(header
); i
++ {
57 // The chksum field (header[148:156]) is special: it should be treated as space bytes.
63 unsigned
+= int64(header
[i
])
64 signed
+= int64(int8(header
[i
]))
71 func (sp
*slicer
) next(n
int) (b
[]byte) {
73 b
, *sp
= s
[0:n
], s
[n
:]