Documentation ¶
Overview ¶
Package tarutil implements some tar utility functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCouldNotExtract occurs when an extraction fails. ErrCouldNotExtract = errors.New("tarutil: could not extract the archive") // ErrExtractedFileTooBig occurs when a file to extract is too big. ErrExtractedFileTooBig = errors.New("tarutil: could not extract one or more files from the archive: file too big") // MaxExtractableFileSize enforces the maximum size of a single file within a // tarball that will be extracted. This protects against malicious files that // may used in an attempt to perform a Denial of Service attack. MaxExtractableFileSize int64 = 200 * 1024 * 1024 // 200 MiB )
Functions ¶
This section is empty.
Types ¶
type TarReadCloser ¶
TarReadCloser embeds a *tar.Reader and the related io.Closer It is the caller's responsibility to call Close on TarReadCloser when done.
func NewTarReadCloser ¶
func NewTarReadCloser(r io.Reader) (*TarReadCloser, error)
NewTarReadCloser attempts to detect the compression algorithm for an io.Reader and returns a TarReadCloser wrapping the Reader to transparently decompress the contents.
Gzip/Bzip2/XZ detection is done by using the magic numbers: Gzip: the first two bytes should be 0x1f and 0x8b. Defined in the RFC1952. Bzip2: the first three bytes should be 0x42, 0x5a and 0x68. No RFC. XZ: the first three bytes should be 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00. No RFC.
func (*TarReadCloser) Close ¶
func (r *TarReadCloser) Close() error
Close cleans up the resources used by a TarReadCloser.
type XzReader ¶
type XzReader struct { io.ReadCloser // contains filtered or unexported fields }
XzReader implements io.ReadCloser for data compressed via `xz`.
func NewXzReader ¶
NewXzReader returns an io.ReadCloser by executing a command line `xz` executable to decompress the provided io.Reader.
It is the caller's responsibility to call Close on the XzReader when done.