archive

package
v0.19.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NormalizedModTime provides a valid "zero" value for ModTime
	NormalizedModTime = time.Date(1980, time.January, 1, 0, 0, 1, 0, time.UTC)
)

Functions

func AddDirToArchive added in v0.8.1

func AddDirToArchive(tw TarWriter, dir string) error

AddDirToArchive walks dir writes entries describing dir and all of its children files to the provided TarWriter

func AddFileToArchive

func AddFileToArchive(tw TarWriter, path string, fi os.FileInfo) error

AddFileToArchive writes an entry describing the file at path with the given os.FileInfo to the provided TarWriter

func AddFilesToArchive added in v0.9.0

func AddFilesToArchive(tw TarWriter, files []PathInfo) error

AddFilesToArchive writes entries describing all files to the provided TarWriter

func Extract added in v0.9.0

func Extract(tr TarReader) error

Extract reads all entries from TarReader and extracts them to the filesystem.

Types

type HeaderOpt added in v0.8.1

type HeaderOpt func(header *tar.Header) *tar.Header

type NormalizingTarReader added in v0.9.0

type NormalizingTarReader struct {
	TarReader
	// contains filtered or unexported fields
}

NormalizingTarReader read from the wrapped TarReader normalizes header before passing them through to the caller NormalizingTarReader always normalizes header.Name so that path separators match the runtime OS Other modifications can be enabled by invoking options on the NormalizingTarReader

func NewNormalizingTarReader added in v0.9.0

func NewNormalizingTarReader(tr TarReader) *NormalizingTarReader

NewNormalizingTarReader creates a NormalizingTarReaders that wraps the provided TarReader

func (*NormalizingTarReader) ExcludePaths added in v0.9.0

func (tr *NormalizingTarReader) ExcludePaths(paths []string)

ExcludedPaths configures an array of paths to be skipped on subsequent calls to Next Children of the configured paths will also be skipped paths should match the unmodified Name of the *tar.Header returned by the wrapped TarReader, not the normalized headers

func (*NormalizingTarReader) Next added in v0.9.0

func (tr *NormalizingTarReader) Next() (*tar.Header, error)

Next calls Next on the wrapped TarReader and applies modifications before returning the *tar.Header If the wrapped TarReader returns a *tar.Header matching an excluded path Next will proceed to the next entry,

returning the first non-excluded entry

Modification options will be apply in the order the options were invoked. Standard modifications (path separators normalization) are applied last.

func (*NormalizingTarReader) PrependDir added in v0.9.0

func (tr *NormalizingTarReader) PrependDir(dir string)

PrependDir will set the Name of any subsequently read *tar.Header the result of filepath.Join of dir and the

original Name

func (*NormalizingTarReader) Strip added in v0.9.0

func (tr *NormalizingTarReader) Strip(prefix string)

Strip removes leading directories for any subsequently read *tar.Header

type NormalizingTarWriter added in v0.9.0

type NormalizingTarWriter struct {
	TarWriter
	// contains filtered or unexported fields
}

NormalizingTarWriter normalizes any written *tar.Header before passing it through to the wrapped TarWriter NormalizingTarWriter always normalizes ModTime, Uname, and Gname Other modifications can be enabled by invoking options on the NormalizingTarWriter

func NewNormalizingTarWriter added in v0.8.1

func NewNormalizingTarWriter(tw TarWriter) *NormalizingTarWriter

NewNormalizingTarWriter creates a NormalizingTarWriter that wraps the provided TarWriter

func (*NormalizingTarWriter) WithGID added in v0.9.0

func (tw *NormalizingTarWriter) WithGID(gid int)

WithGID sets Gid of any subsequently written *tar.Header to gid

func (*NormalizingTarWriter) WithModTime added in v0.9.0

func (tw *NormalizingTarWriter) WithModTime(modTime time.Time)

WithModTime sets the ModTime of any subsequently written *tar.Header to modTime

func (*NormalizingTarWriter) WithUID added in v0.9.0

func (tw *NormalizingTarWriter) WithUID(uid int)

WithUID sets Uid of any subsequently written *tar.Header to uid

func (*NormalizingTarWriter) WriteHeader added in v0.9.0

func (tw *NormalizingTarWriter) WriteHeader(hdr *tar.Header) error

WriteHeader writes the header to the wrapped TarWriter after applying standard and configured modifications Modification options will be apply in the order the options were invoked. Standard modification (ModTime, Uname, and Gname) are applied last.

type PathInfo added in v0.8.1

type PathInfo struct {
	Path string
	Info os.FileInfo
}

PathInfo associates a path with an os.FileInfo

type PathMode

type PathMode struct {
	Path string
	Mode os.FileMode
}

type TarReader added in v0.9.0

type TarReader interface {
	Next() (*tar.Header, error)
	Read(b []byte) (int, error)
}

type TarWriter added in v0.8.1

type TarWriter interface {
	WriteHeader(hdr *tar.Header) error
	Write(b []byte) (int, error)
	Close() error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL