archive

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEntryNotExist = errors.New("not exist")
View Source
var NormalizedDateTime time.Time

Functions

func AddFileToTar

func AddFileToTar(tw *tar.Writer, path string, txt string) error

func CreateSingleFileTar

func CreateSingleFileTar(tarFile, path, txt string) error

func CreateSingleFileTarReader

func CreateSingleFileTarReader(path, txt string) (io.Reader, error)

func GenerateTar

func GenerateTar(gen func(*tar.Writer) error) io.ReadCloser

GenerateTar returns a reader to a tar from a generator function. Note that the generator will not fully execute until the reader is fully read from. Any errors returned by the generator will be returned when reading the reader.

func IsEntryNotExist added in v0.10.0

func IsEntryNotExist(err error) bool

func IsZip

func IsZip(file io.Reader) (bool, error)

func NormalizeHeader

func NormalizeHeader(header *tar.Header, normalizeModTime bool)

NormalizeHeader normalizes a tar.Header

Normalizes the following:

  • ModTime
  • GID
  • UID
  • User Name
  • Group Name

func ReadDirAsTar

func ReadDirAsTar(srcDir, basePath string, uid, gid int, mode int64, normalizeModTime bool, fileFilter func(string) bool) io.ReadCloser

func ReadTarEntry

func ReadTarEntry(rc io.Reader, entryPath string) (*tar.Header, []byte, error)

func ReadZipAsTar

func ReadZipAsTar(srcPath, basePath string, uid, gid int, mode int64, normalizeModTime bool, fileFilter func(string) bool) io.ReadCloser

func WriteDirToTar

func WriteDirToTar(tw *tar.Writer, srcDir, basePath string, uid, gid int, mode int64, normalizeModTime bool, fileFilter func(string) bool) error

WriteDirToTar writes the contents of a directory to a tar writer. `basePath` is the "location" in the tar the contents will be places.

func WriteZipToTar

func WriteZipToTar(tw *tar.Writer, srcZip, basePath string, uid, gid int, mode int64, normalizeModTime bool, fileFilter func(string) bool) error

Types

type TarBuilder

type TarBuilder struct {
	// contains filtered or unexported fields
}

func (*TarBuilder) AddDir

func (t *TarBuilder) AddDir(path string, mode int64, modTime time.Time)

func (*TarBuilder) AddFile

func (t *TarBuilder) AddFile(path string, mode int64, modTime time.Time, contents []byte)

func (*TarBuilder) Reader

func (t *TarBuilder) Reader() io.ReadCloser

func (*TarBuilder) WriteTo

func (t *TarBuilder) WriteTo(writer io.Writer) (int64, error)

func (*TarBuilder) WriteToPath

func (t *TarBuilder) WriteToPath(path string) error

Jump to

Keyboard shortcuts

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