archive

package
v0.14.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 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")

ErrEntryNotExist is an error returned if an entry path doesn't exist

View Source
var NormalizedDateTime time.Time

Functions

func CreateSingleFileTar

func CreateSingleFileTar(tarFile, path, txt string) error

func CreateSingleFileTarReader

func CreateSingleFileTarReader(path, txt string) io.ReadCloser

func GenerateTar

func GenerateTar(genFn func(TarWriter) error) io.ReadCloser

func GenerateTarWithWriter added in v0.11.0

func GenerateTarWithWriter(genFn func(TarWriter) error, twf TarWriterFactory) io.ReadCloser

GenerateTarWithTar returns a reader to a tar from a generator function using a writer from the provided factory. 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

IsEntryNotExist detects whether a given error is of type ErrEntryNotExist

func IsZip

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

IsZip detects whether or not a File is a zip directory

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)

ReadTarEntry reads and returns a tar file

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 TarWriter, 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 placed.

func WriteZipToTar

func WriteZipToTar(tw TarWriter, srcZip, basePath string, uid, gid int, mode int64, normalizeModTime bool, fileFilter func(string) bool) error

WriteZipToTar writes the contents of a zip file to a tar writer.

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(twf TarWriterFactory) io.ReadCloser

func (*TarBuilder) WriteTo

func (t *TarBuilder) WriteTo(w io.Writer, twf TarWriterFactory) (int64, error)

func (*TarBuilder) WriteToPath

func (t *TarBuilder) WriteToPath(path string, twf TarWriterFactory) error

type TarWriter added in v0.11.0

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

type TarWriterFactory added in v0.11.0

type TarWriterFactory interface {
	NewWriter(io.Writer) TarWriter
}

func DefaultTarWriterFactory added in v0.11.0

func DefaultTarWriterFactory() TarWriterFactory

Jump to

Keyboard shortcuts

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