archive

package
v0.113.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TarEntries

func TarEntries(r io.Reader) ([]string, error)

TarEntries interprets the given io.Reader as a tar archive, outputting a list of filenames contained within it

Types

type TarBuilder

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

TarBuilder writes a .tar archive to an io.Writer. The contents of the archive are determined by successive calls to `File` and `RecursiveDir`.

If an error occurs during processing, all subsequent calls to TarWriter will fail with that same error. The same error will be returned by `Err()`.

TarBuilder is **not** safe for concurrent use.

func NewTarBuilder

func NewTarBuilder(basePath string, w io.Writer) *TarBuilder

NewTarBuilder creates a TarBuilder that writes files from basePath on the filesystem to the given io.Writer

func (*TarBuilder) Close

func (t *TarBuilder) Close() error

Close finalizes the archive and releases any underlying resources. It should always be called, whether an error has been encountered in processing or not.

func (*TarBuilder) Err

func (t *TarBuilder) Err() error

Err returns the last error seen during operation of a TarBuilder. Once an error has been encountered, the TarBuilder will cease further operations. It is safe to make a series of calls, then just check `Err()` at the end.

func (*TarBuilder) File

func (t *TarBuilder) File(rel string, mustExist bool) error

File writes a single regular file to the archive. It is an error if the file exists, but is not a regular file - including symlinks.

If `mustExist` is set, an error is returned if the file doesn't exist. Otherwise, the error is hidden.

func (*TarBuilder) FileIfExist

func (t *TarBuilder) FileIfExist(rel string) error

FileIfExist is a helper for File that sets `mustExist` to false.

func (*TarBuilder) RecursiveDir

func (t *TarBuilder) RecursiveDir(rel string, mustExist bool, patterns ...*regexp.Regexp) error

RecursiveDir adds a complete directory to the archive, including all subdirectories and any regular files in the tree. Anything that is not a regular file (including symlinks, etc) will be **skipped**.

If `mustExist` is true, an error is returned if the root directory doesn't exist. Otherwise, the error is hidden.

If patterns is non-empty, only those matching files and directories will be included. Otherwise, all are included.

func (*TarBuilder) RecursiveDirIfExist

func (t *TarBuilder) RecursiveDirIfExist(rel string, patterns ...*regexp.Regexp) error

RecursiveDirIfExist is a helper for RecursiveDir that sets `mustExist` to false.

Jump to

Keyboard shortcuts

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