tatar

package module
v0.0.0-...-f936f87 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompressionType

type CompressionType int

CompressionType specifies the compression. Valid values: NO_COMPRESSION, GZIP, BZIP2, LZMA

const (
	NO_COMPRESSION CompressionType = iota
	GZIP
	BZIP2
	LZMA
)

func GuessCompression

func GuessCompression(name string) CompressionType

GuessCompression guesses the compression type by fileextension

type Tar

type Tar struct {
	Data        []byte
	Compression CompressionType
}

Tar contains the uncompressed tar data and the desired Compression This is the main struct of this packet

func NewFromData

func NewFromData(data []byte, compression CompressionType) (*Tar, error)

NewFromData loades a datablob with the specified compression

func NewFromDirectory

func NewFromDirectory(directory string) (*Tar, error)

NewFromDirectory creates a tar archive from the contents (!) of the given directory

func NewFromFile

func NewFromFile(path string) (*Tar, error)

NewFromFile loades a tar from a file. CompressionType is guessed by fileextension

func (*Tar) ForEach

func (t *Tar) ForEach(cb func(header *tar.Header, reader io.Reader) error) error

ForEach iterates over the tars contents, and calls the given callback for each entity (directories and files)

func (*Tar) GetReader

func (t *Tar) GetReader() *tar.Reader

GetReader returns a *tar.Reader from the stdlib

func (*Tar) Load

func (t *Tar) Load(in io.Reader) (int64, error)

Load decompresses the tar from the specified reader

func (*Tar) Save

func (t *Tar) Save(out io.Writer) (int64, error)

Save compresses the tar into the specified writer

func (*Tar) ToData

func (t *Tar) ToData() ([]byte, error)

func (*Tar) ToDirectory

func (t *Tar) ToDirectory(path string) error

ToDirectory extracts the tars contents into the given directory

func (*Tar) ToFile

func (t *Tar) ToFile(path string) (int64, error)

ToFile saves the tar to a file If CompressionType is undefined (NO_COMPRESSION) it is guessed by fileextension

Jump to

Keyboard shortcuts

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