Involved Source Files Package tar implements access to tar archives.
Tape archives (tar) are a file format for storing a sequence of files that
can be read and written in a streaming manner.
This package aims to cover most variations of the format,
including those produced by GNU and BSD tar tools.format.goreader.gostat_actime1.gostat_unix.gostrconv.gowriter.go
Code Examples
package main
import (
"archive/tar"
"bytes"
"fmt"
"io"
"log"
"os"
)
func main() {
// Create and add some files to the archive.
var buf bytes.Buffer
tw := tar.NewWriter(&buf)
var files = []struct {
Name, Body string
}{
{"readme.txt", "This archive contains some text files."},
{"gopher.txt", "Gopher names:\nGeorge\nGeoffrey\nGonzo"},
{"todo.txt", "Get animal handling license."},
}
for _, file := range files {
hdr := &tar.Header{
Name: file.Name,
Mode: 0600,
Size: int64(len(file.Body)),
}
if err := tw.WriteHeader(hdr); err != nil {
log.Fatal(err)
}
if _, err := tw.Write([]byte(file.Body)); err != nil {
log.Fatal(err)
}
}
if err := tw.Close(); err != nil {
log.Fatal(err)
}
// Open and iterate through the files in the archive.
tr := tar.NewReader(&buf)
for {
hdr, err := tr.Next()
if err == io.EOF {
break // End of archive
}
if err != nil {
log.Fatal(err)
}
fmt.Printf("Contents of %s:\n", hdr.Name)
if _, err := io.Copy(os.Stdout, tr); err != nil {
log.Fatal(err)
}
fmt.Println()
}
}
Package-Level Type Names (total 30, in which 5 are exported)
/* sort exporteds by: | */
FileInfoNames extends [fs.FileInfo].
Passing an instance of this to [FileInfoHeader] permits the caller
to avoid a system-dependent name lookup by specifying the Uname and Gname directly. Gname should give a group name. // abbreviation for Mode().IsDir() // modification time // file mode bits // base name of the file // length in bytes for regular files; system-dependent for others // underlying data source (can return nil) Uname should give a user name.
FileInfoNames : io/fs.FileInfo
Format represents the tar archive format.
The original tar format was introduced in Unix V7.
Since then, there have been multiple competing formats attempting to
standardize or extend the V7 format to overcome its limitations.
The most common formats are the USTAR, PAX, and GNU formats,
each with their own advantages and limitations.
The following table captures the capabilities of each format:
| USTAR | PAX | GNU
------------------+--------+-----------+----------
Name | 256B | unlimited | unlimited
Linkname | 100B | unlimited | unlimited
Size | uint33 | unlimited | uint89
Mode | uint21 | uint21 | uint57
Uid/Gid | uint21 | unlimited | uint57
Uname/Gname | 32B | unlimited | 32B
ModTime | uint33 | unlimited | int89
AccessTime | n/a | unlimited | int89
ChangeTime | n/a | unlimited | int89
Devmajor/Devminor | uint21 | uint21 | uint57
------------------+--------+-----------+----------
string encoding | ASCII | UTF-8 | binary
sub-second times | no | yes | no
sparse files | no | yes | yes
The table's upper portion shows the [Header] fields, where each format reports
the maximum number of bytes allowed for each string field and
the integer type used to store each numeric field
(where timestamps are stored as the number of seconds since the Unix epoch).
The table's lower portion shows specialized features of each format,
such as supported string encodings, support for sub-second timestamps,
or support for sparse files.
The Writer currently provides no support for sparse files.( Format) String() string( Format) has(f2 Format) bool(*Format) mayBe(f2 Format)(*Format) mayOnlyBe(f2 Format)(*Format) mustNotBe(f2 Format)
Format : expvar.Var
Format : fmt.Stringer
Format : context.stringer
Format : os/signal.stringer
Format : runtime.stringer
func Header.allowedFormats() (format Format, paxHdrs map[string]string, err error)
func Format.has(f2 Format) bool
func (*Format).mayBe(f2 Format)
func (*Format).mayOnlyBe(f2 Format)
func (*Format).mustNotBe(f2 Format)
func (*Writer).writeRawFile(name, data string, flag byte, format Format) error
const FormatGNU
const FormatPAX
const FormatUnknown
const FormatUSTAR
const formatMax
const formatSTAR
const formatV7
A Header represents a single header in a tar archive.
Some fields may not be populated.
For forward compatibility, users that retrieve a Header from Reader.Next,
mutate it in some ways, and then pass it back to Writer.WriteHeader
should do so by creating a new Header and copying the fields
that they are interested in preserving. // Access time (requires either PAX or GNU support) // Change time (requires either PAX or GNU support) // Major device number (valid for TypeChar or TypeBlock) // Minor device number (valid for TypeChar or TypeBlock) Format specifies the format of the tar header.
This is set by Reader.Next as a best-effort guess at the format.
Since the Reader liberally reads some non-compliant files,
it is possible for this to be FormatUnknown.
If the format is unspecified when Writer.WriteHeader is called,
then it uses the first format (in the order of USTAR, PAX, GNU)
capable of encoding this Header (see Format). // Group ID of owner // Group name of owner // Target name of link (valid for TypeLink or TypeSymlink) If the Format is unspecified, then Writer.WriteHeader rounds ModTime
to the nearest second and ignores the AccessTime and ChangeTime fields.
To use AccessTime or ChangeTime, specify the Format as PAX or GNU.
To use sub-second resolution, specify the Format as PAX. // Modification time // Permission and mode bits // Name of file entry PAXRecords is a map of PAX extended header records.
User-defined records should have keys of the following form:
VENDOR.keyword
Where VENDOR is some namespace in all uppercase, and keyword may
not contain the '=' character (e.g., "GOLANG.pkg.version").
The key and value should be non-empty UTF-8 strings.
When Writer.WriteHeader is called, PAX records derived from the
other fields in Header take precedence over PAXRecords. // Logical file size in bytes Typeflag is the type of header entry.
The zero value is automatically promoted to either TypeReg or TypeDir
depending on the presence of a trailing slash in Name. // User ID of owner // User name of owner Xattrs stores extended attributes as PAX records under the
"SCHILY.xattr." namespace.
The following are semantically equivalent:
h.Xattrs[key] = value
h.PAXRecords["SCHILY.xattr."+key] = value
When Writer.WriteHeader is called, the contents of Xattrs will take
precedence over those in PAXRecords.
Deprecated: Use PAXRecords instead. FileInfo returns an fs.FileInfo for the Header. allowedFormats determines which formats can be used.
The value returned is the logical OR of multiple possible formats.
If the value is FormatUnknown, then the input Header cannot be encoded
and an error is returned explaining why.
As a by-product of checking the fields, this function returns paxHdrs, which
contain all fields that could not be directly encoded.
A value receiver ensures that this method does not mutate the source Header.
func FileInfoHeader(fi fs.FileInfo, link string) (*Header, error)
func (*Reader).Next() (*Header, error)
func (*Reader).next() (*Header, error)
func (*Reader).readHeader() (*Header, *block, error)
func (*Writer).WriteHeader(hdr *Header) error
func mergePAX(hdr *Header, paxHdrs map[string]string) (err error)
func statUnix(fi fs.FileInfo, h *Header, doNameLookups bool) error
func (*Reader).handleRegularFile(hdr *Header) error
func (*Reader).handleSparseFile(hdr *Header, rawHdr *block) error
func (*Reader).readGNUSparsePAXHeaders(hdr *Header) (sparseDatas, error)
func (*Reader).readOldGNUSparseMap(hdr *Header, blk *block) (sparseDatas, error)
func (*Writer).templateV7Plus(hdr *Header, fmtStr stringFormatter, fmtNum numberFormatter) *block
func (*Writer).writeGNUHeader(hdr *Header) error
func (*Writer).writePAXHeader(hdr *Header, paxHdrs map[string]string) error
func (*Writer).writeUSTARHeader(hdr *Header) error
Reader provides sequential access to the contents of a tar archive.
Reader.Next advances to the next file in the archive (including the first),
and then Reader can be treated as an io.Reader to access the file's data. // Buffer to use as temporary local storage // Reader for current file entry err is a persistent error.
It is only the responsibility of every exported method of Reader to
ensure that this error is sticky. // Amount of padding (ignored) after current file entryrio.Reader Next advances to the next entry in the tar archive.
The Header.Size determines how many bytes can be read for the next file.
Any remaining data in the current file is automatically discarded.
At the end of the archive, Next returns the error io.EOF.
If Next encounters a non-local file name (as defined by [filepath.IsLocal])
and the GODEBUG environment variable contains `tarinsecurepath=0`,
Only file names are validated, not link targets.
Next returns the header with an [ErrInsecurePath] error.
A future version of Go may introduce this behavior by default.
Programs that want to accept non-local names can ignore
the [ErrInsecurePath] error and use the returned header. Read reads from the current file in the tar archive.
It returns (0, io.EOF) when it reaches the end of that file,
until [Next] is called to advance to the next file.
If the current file is sparse, then the regions marked as a hole
are read back as NUL-bytes.
Calling Read on special types like [TypeLink], [TypeSymlink], [TypeChar],
[TypeBlock], [TypeDir], and [TypeFifo] returns (0, [io.EOF]) regardless of what
the [Header.Size] claims. handleRegularFile sets up the current file reader and padding such that it
can only read the following logical data section. It will properly handle
special headers that contain no data section. handleSparseFile checks if the current file is a sparse format of any type
and sets the curr reader appropriately.(*Reader) next() (*Header, error) readGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers.
If they are found, then this function reads the sparse map and returns it.
This assumes that 0.0 headers have already been converted to 0.1 headers
by the PAX header parsing logic. readHeader reads the next block header and assumes that the underlying reader
is already aligned to a block boundary. It returns the raw block of the
header in case further processing is required.
The err will be set to io.EOF only when one of the following occurs:
- Exactly 0 bytes are read and EOF is hit.
- Exactly 1 block of zeros is read and EOF is hit.
- At least 2 blocks of zeros are read. readOldGNUSparseMap reads the sparse map from the old GNU sparse format.
The sparse map is stored in the tar header if it's small enough.
If it's larger than four entries, then one or more extension headers are used
to store the rest of the sparse map.
The Header.Size does not reflect the size of any extended headers used.
Thus, this function will read from the raw io.Reader to fetch extra headers.
This method mutates blk in the process. writeTo writes the content of the current file to w.
The bytes written matches the number of remaining bytes in the current file.
If the current file is sparse and w is an io.WriteSeeker,
then writeTo uses Seek to skip past holes defined in Header.SparseHoles,
assuming that skipped regions are filled with NULs.
This always writes the last byte to ensure w is the right size.
TODO(dsnet): Re-export this when adding sparse file support.
See https://golang.org/issue/22735
*Reader : io.Reader
func NewReader(r io.Reader) *Reader
Writer provides sequential writing of a tar archive.
[Writer.WriteHeader] begins a new file with the provided [Header],
and then Writer can be treated as an io.Writer to supply that file's data. // Buffer to use as temporary local storage // Writer for current file entry err is a persistent error.
It is only the responsibility of every exported method of Writer to
ensure that this error is sticky. // Shallow copy of Header that is safe for mutations // Amount of padding to write after current file entrywio.Writer AddFS adds the files from fs.FS to the archive.
It walks the directory tree starting at the root of the filesystem
adding each file to the tar archive while maintaining the directory structure. Close closes the tar archive by flushing the padding, and writing the footer.
If the current file (from a prior call to [Writer.WriteHeader]) is not fully written,
then this returns an error. Flush finishes writing the current file's block padding.
The current file must be fully written before Flush can be called.
This is unnecessary as the next call to [Writer.WriteHeader] or [Writer.Close]
will implicitly flush out the file's padding. Write writes to the current file in the tar archive.
Write returns the error [ErrWriteTooLong] if more than
Header.Size bytes are written after [Writer.WriteHeader].
Calling Write on special types like [TypeLink], [TypeSymlink], [TypeChar],
[TypeBlock], [TypeDir], and [TypeFifo] returns (0, [ErrWriteTooLong]) regardless
of what the [Header.Size] claims. WriteHeader writes hdr and prepares to accept the file's contents.
The Header.Size determines how many bytes can be written for the next file.
If the current file is not fully written, then this returns an error.
This implicitly flushes any padding necessary before writing the header. readFrom populates the content of the current file by reading from r.
The bytes read must match the number of remaining bytes in the current file.
If the current file is sparse and r is an io.ReadSeeker,
then readFrom uses Seek to skip past holes defined in Header.SparseHoles,
assuming that skipped regions are all NULs.
This always reads the last byte to ensure r is the right size.
TODO(dsnet): Re-export this when adding sparse file support.
See https://golang.org/issue/22735 templateV7Plus fills out the V7 fields of a block using values from hdr.
It also fills out fields (uname, gname, devmajor, devminor) that are
shared in the USTAR, PAX, and GNU formats using the provided formatters.
The block returned is only valid until the next call to
templateV7Plus or writeRawFile.(*Writer) writeGNUHeader(hdr *Header) error(*Writer) writePAXHeader(hdr *Header, paxHdrs map[string]string) error writeRawFile writes a minimal file with the given name and flag type.
It uses format to encode the header format and will write data as the body.
It uses default values for all of the other fields (as BSD and GNU tar does). writeRawHeader writes the value of blk, regardless of its value.
It sets up the Writer such that it can accept a file of the given size.
If the flag is a special header-only flag, then the size is treated as zero.(*Writer) writeUSTARHeader(hdr *Header) error
*Writer : internal/bisect.Writer
*Writer : io.Closer
*Writer : io.WriteCloser
*Writer : io.Writer
*Writer : crypto/tls.transcriptHash
func NewWriter(w io.Writer) *Writer
// Last error seen formatNumeric encodes x into b using base-8 (octal) encoding if possible.
Otherwise it will attempt to use base-256 (binary) encoding.(*formatter) formatOctal(b []byte, x int64) formatString copies s into b, NUL-terminating if possible.
headerFileInfo implements fs.FileInfo.h*Header( headerFileInfo) IsDir() bool( headerFileInfo) ModTime() time.Time Mode returns the permission and mode bits for the headerFileInfo. Name returns the base name of the file.( headerFileInfo) Size() int64( headerFileInfo) String() string( headerFileInfo) Sys() any
headerFileInfo : expvar.Var
headerFileInfo : fmt.Stringer
headerFileInfo : io/fs.FileInfo
headerFileInfo : context.stringer
headerFileInfo : os/signal.stringer
headerFileInfo : runtime.stringer
// Last error seen parseNumeric parses the input as being encoded in either base-256 or octal.
This function may return negative numbers.
If parsing fails or an integer overflow occurs, err will be set.(*parser) parseOctal(b []byte) int64 parseString parses bytes as a NUL-terminated C-style string.
If a NUL byte is not found then the whole slice is returned as a string.
regFileReader is a fileReader for reading data from a regular file entry. // Number of remaining bytes to read // Underlying Reader(*regFileReader) Read(b []byte) (n int, err error)(*regFileReader) WriteTo(w io.Writer) (int64, error) logicalRemaining implements fileState.logicalRemaining. physicalRemaining implements fileState.physicalRemaining.
*regFileReader : io.Reader
*regFileReader : io.WriterTo
*regFileReader : fileReader
regFileReader : fileState
regFileWriter is a fileWriter for writing data to a regular file entry. // Number of remaining bytes to write // Underlying Writer(*regFileWriter) ReadFrom(r io.Reader) (int64, error)(*regFileWriter) Write(b []byte) (n int, err error) logicalRemaining implements fileState.logicalRemaining. physicalRemaining implements fileState.physicalRemaining.
*regFileWriter : internal/bisect.Writer
*regFileWriter : io.ReaderFrom
*regFileWriter : io.Writer
regFileWriter : fileState
*regFileWriter : fileWriter
*regFileWriter : crypto/tls.transcriptHash
A sparse file can be represented as either a sparseDatas or a sparseHoles.
As long as the total size is known, they are equivalent and one can be
converted to the other form and back. The various tar formats with sparse
file support represent sparse files in the sparseDatas form. That is, they
specify the fragments in the file that has data, and treat everything else as
having zero bytes. As such, the encoding and decoding logic in this package
deals with sparseDatas.
However, the external API uses sparseHoles instead of sparseDatas because the
zero value of sparseHoles logically represents a normal file (i.e., there are
no holes in it). On the other hand, the zero value of sparseDatas implies
that the file has no data in it, which is rather odd.
As an example, if the underlying raw file contains the 10-byte data:
var compactFile = "abcdefgh"
And the sparse map has the following entries:
var spd sparseDatas = []sparseEntry{
{Offset: 2, Length: 5}, // Data fragment for 2..6
{Offset: 18, Length: 3}, // Data fragment for 18..20
}
var sph sparseHoles = []sparseEntry{
{Offset: 0, Length: 2}, // Hole fragment for 0..1
{Offset: 7, Length: 11}, // Hole fragment for 7..17
{Offset: 21, Length: 4}, // Hole fragment for 21..24
}
Then the content of the resulting sparse file with a Header.Size of 25 is:
var sparseFile = "\x00"*2 + "abcde" + "\x00"*11 + "fgh" + "\x00"*4
func appendSparseEntry(spd sparseDatas, ent sparseEntry) (sparseDatas, error)
func readGNUSparseMap0x1(paxHdrs map[string]string) (sparseDatas, error)
func readGNUSparseMap1x0(r io.Reader) (sparseDatas, error)
func (*Reader).readGNUSparsePAXHeaders(hdr *Header) (sparseDatas, error)
func (*Reader).readOldGNUSparseMap(hdr *Header, blk *block) (sparseDatas, error)
func appendSparseEntry(spd sparseDatas, ent sparseEntry) (sparseDatas, error)
sparseFileReader is a fileReader for reading data from a sparse file entry. // Underlying fileReader // Current position in sparse file // Normalized list of sparse holes(*sparseFileReader) Read(b []byte) (n int, err error)(*sparseFileReader) WriteTo(w io.Writer) (n int64, err error)( sparseFileReader) logicalRemaining() int64( sparseFileReader) physicalRemaining() int64
*sparseFileReader : io.Reader
*sparseFileReader : io.WriterTo
*sparseFileReader : fileReader
sparseFileReader : fileState
sparseFileWriter is a fileWriter for writing data to a sparse file entry. // Underlying fileWriter // Current position in sparse file // Normalized list of data fragments(*sparseFileWriter) ReadFrom(r io.Reader) (n int64, err error)(*sparseFileWriter) Write(b []byte) (n int, err error)( sparseFileWriter) logicalRemaining() int64( sparseFileWriter) physicalRemaining() int64
*sparseFileWriter : internal/bisect.Writer
*sparseFileWriter : io.ReaderFrom
*sparseFileWriter : io.Writer
sparseFileWriter : fileState
*sparseFileWriter : fileWriter
*sparseFileWriter : crypto/tls.transcriptHash
A sparse file can be represented as either a sparseDatas or a sparseHoles.
As long as the total size is known, they are equivalent and one can be
converted to the other form and back. The various tar formats with sparse
file support represent sparse files in the sparseDatas form. That is, they
specify the fragments in the file that has data, and treat everything else as
having zero bytes. As such, the encoding and decoding logic in this package
deals with sparseDatas.
However, the external API uses sparseHoles instead of sparseDatas because the
zero value of sparseHoles logically represents a normal file (i.e., there are
no holes in it). On the other hand, the zero value of sparseDatas implies
that the file has no data in it, which is rather odd.
As an example, if the underlying raw file contains the 10-byte data:
var compactFile = "abcdefgh"
And the sparse map has the following entries:
var spd sparseDatas = []sparseEntry{
{Offset: 2, Length: 5}, // Data fragment for 2..6
{Offset: 18, Length: 3}, // Data fragment for 18..20
}
var sph sparseHoles = []sparseEntry{
{Offset: 0, Length: 2}, // Hole fragment for 0..1
{Offset: 7, Length: 11}, // Hole fragment for 7..17
{Offset: 21, Length: 4}, // Hole fragment for 21..24
}
Then the content of the resulting sparse file with a Header.Size of 25 is:
var sparseFile = "\x00"*2 + "abcde" + "\x00"*11 + "fgh" + "\x00"*4
zeroWriter may only be written with NULs, otherwise it returns errWriteHole.( zeroWriter) Write(b []byte) (int, error)
zeroWriter : internal/bisect.Writer
zeroWriter : io.Writer
zeroWriter : crypto/tls.transcriptHash
Package-Level Functions (total 33, in which 3 are exported)
FileInfoHeader creates a partially-populated [Header] from fi.
If fi describes a symlink, FileInfoHeader records link as the link target.
If fi describes a directory, a slash is appended to the name.
Since fs.FileInfo's Name method only returns the base name of
the file it describes, it may be necessary to modify Header.Name
to provide the full path name of the file.
If fi implements [FileInfoNames]
Header.Gname and Header.Uname
are provided by the methods of the interface.
NewReader creates a new [Reader] reading from r.
NewWriter creates a new Writer writing to w.
alignSparseEntries mutates src and returns dst where each fragment's
starting offset is aligned up to the nearest block edge, and each
ending offset is aligned down to the nearest block edge.
Even though the Go tar Reader and the BSD tar utility can handle entries
with arbitrary offsets and lengths, the GNU tar utility can only handle
offsets and lengths that are multiples of blockSize.
blockPadding computes the number of bytes needed to pad offset up to the
nearest block edge where 0 <= n < blockSize.
discard skips n bytes in r, reporting an error if unable to do so.
ensureEOF checks whether r is at EOF, reporting ErrWriteTooLong if not so.
fitsInBase256 reports whether x can be encoded into n bytes using base-256
encoding. Unlike octal encoding, base-256 encoding does not require that the
string ends with a NUL character. Thus, all n bytes are available for output.
If operating in binary mode, this assumes strict GNU binary mode; which means
that the first byte can only be either 0x80 or 0xff. Thus, the first byte is
equivalent to the sign bit in two's complement form.
fitsInOctal reports whether the integer x fits in a field n-bytes long
using octal encoding with the appropriate NUL terminator.
formatPAXRecord formats a single PAX record, prefixing it with the
appropriate length.
formatPAXTime converts ts into a time of the form %d.%d as described in the
PAX specification. This function is capable of negative timestamps.
hasNUL reports whether the NUL character exists within s.
invertSparseEntries converts a sparse map from one form to the other.
If the input is sparseHoles, then it will output sparseDatas and vice-versa.
The input must have been already validated.
This function mutates src and returns a normalized map where:
- adjacent fragments are coalesced together
- only the last fragment may be empty
- the endOffset of the last fragment is the total size
isASCII reports whether the input is an ASCII C-style string.
isHeaderOnlyType checks if the given type flag is of the type that has no
data section even if a size is specified.
mergePAX merges paxHdrs into hdr for all relevant fields of Header.
mustReadFull is like io.ReadFull except it returns
io.ErrUnexpectedEOF when io.EOF is hit before len(b) bytes are read.
parsePAX parses PAX headers.
If an extended header (type 'x') is invalid, ErrHeader is returned.
parsePAXRecord parses the input PAX record string into a key-value pair.
If parsing is successful, it will slice off the currently read record and
return the remainder as r.
parsePAXTime takes a string of the form %d.%d as described in the PAX
specification. Note that this implementation allows for negative timestamps,
which is allowed for by the PAX specification, but not always portable.
readGNUSparseMap0x1 reads the sparse map as stored in GNU's PAX sparse format
version 0.1. The sparse map is stored in the PAX headers.
readGNUSparseMap1x0 reads the sparse map as stored in GNU's PAX sparse format
version 1.0. The format of the sparse map consists of a series of
newline-terminated numeric fields. The first field is the number of entries
and is always present. Following this are the entries, consisting of two
fields (offset, length). This function must stop reading at the end
boundary of the block containing the last newline.
Note that the GNU manual says that numeric values should be encoded in octal
format. However, the GNU tar utility itself outputs these values in decimal.
As such, this library treats values as being encoded in decimal.
readSpecialFile is like io.ReadAll except it returns
ErrFieldTooLong if more than maxSpecialFileSize is read.
splitUSTARPath splits a path according to USTAR prefix and suffix rules.
If the path is not splittable, then it will return ("", "", false).
toASCII converts the input to an ASCII C-style string.
This is a best effort conversion, so invalid characters are dropped.
tryReadFull is like io.ReadFull except it returns
io.EOF when it is hit before len(b) bytes are read.
validateSparseEntries reports whether sp is a valid sparse map.
It does not matter whether sp represents data fragments or hole fragments.
validPAXRecord reports whether the key-value pair is valid where each
record is formatted as:
"%d %s=%s\n" % (size, key, value)
Keys and values should be UTF-8, but the number of bad writers out there
forces us to be more liberal.
Thus, we only reject all keys with NUL, and only reject NULs in values
for the PAX version of the USTAR string fields.
The key must not contain an '=' character.
Package-Level Variables (total 16, in which 5 are exported)
basicKeys is a set of the PAX keys for which we have built-in support.
This does not contain "charset" or "comment", which are both PAX-specific,
so adding them as first-class features of Header is unlikely.
Users can use the PAXRecords field to set it themselves.
Package-Level Constants (total 65, in which 18 are exported)
FormatGNU represents the GNU header format.
The GNU header format is older than the USTAR and PAX standards and
is not compatible with them. The GNU format supports
arbitrary file sizes, filenames of arbitrary encoding and length,
sparse files, and other features.
It is recommended that PAX be chosen over GNU unless the target
application can only parse GNU formatted archives.
Reference:
https://www.gnu.org/software/tar/manual/html_node/Standard.html
FormatPAX represents the PAX header format defined in POSIX.1-2001.
PAX extends USTAR by writing a special file with Typeflag TypeXHeader
preceding the original header. This file contains a set of key-value
records, which are used to overcome USTAR's shortcomings, in addition to
providing the ability to have sub-second resolution for timestamps.
Some newer formats add their own extensions to PAX by defining their
own keys and assigning certain semantic meaning to the associated values.
For example, sparse file support in PAX is implemented using keys
defined by the GNU manual (e.g., "GNU.sparse.map").
Reference:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/pax.html
FormatUnknown indicates that the format is unknown.
FormatUSTAR represents the USTAR header format defined in POSIX.1-1988.
While this format is compatible with most tar readers,
the format has several limitations making it unsuitable for some usages.
Most notably, it cannot support sparse files, files larger than 8GiB,
filenames larger than 256 characters, and non-ASCII filenames.
Reference:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_06
Type flags for Header.Typeflag.
Type flags for Header.Typeflag.
Type '7' is reserved.
Type flags for Header.Typeflag.
Type flags for Header.Typeflag.
Type flags for Header.Typeflag.
Types 'L' and 'K' are used by the GNU format for a meta file
used to store the path or link name for the next file.
This package transparently handles these types.
Type 'S' indicates a sparse file in the GNU format.
Type '1' to '6' are header-only flags and may not have a data body.
Type '0' indicates a regular file.
Deprecated: Use TypeReg instead.
Type flags for Header.Typeflag.
Type 'g' is used by the PAX format to store key-value records that
are relevant to all subsequent files.
This package only supports parsing and composing such headers,
but does not currently support persisting the global state across files.
Type 'x' is used by the PAX format to store key-value records that
are only relevant to the next file.
This package transparently handles these types.
Common Unix mode constants; these are not defined in any common tar standard.
Header.FileInfo understands these, but FileInfoHeader will never produce these.
Schily's tar format, which is incompatible with USTAR.
This does not cover STAR extensions to the PAX format; these fall under
the PAX format.
The format of the original Unix V7 tar tool prior to standardization.
Magics used to identify various formats.
Magics used to identify various formats.
Maximum number of sparse file entries.
We should never actually hit this limit
(every sparse encoding will first be limited by maxSpecialFileSize),
but this adds an additional layer of defense.
Max length of a special file (PAX header, GNU long name or link).
This matches the limit used by libarchive.
Size constants from various tar specifications.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for GNU sparse files in a PAX extended header.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Keywords for PAX extended header records.
Size constants from various tar specifications.
Magics used to identify various formats.
Magics used to identify various formats.
Magics used to identify various formats.
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)