Documentation ¶
Index ¶
- func TarEntries(r io.Reader) ([]string, error)
- type MatchWalker
- type TarBuilder
- func (t *TarBuilder) Close() error
- func (t *TarBuilder) Err() error
- func (t *TarBuilder) File(rel string, mustExist bool) error
- func (t *TarBuilder) FileIfExist(rel string) error
- func (t *TarBuilder) RecursiveDir(rel string, mustExist bool, patterns ...*regexp.Regexp) error
- func (t *TarBuilder) RecursiveDirIfExist(rel string, patterns ...*regexp.Regexp) error
- func (t *TarBuilder) VirtualFileWithContents(relPath string, contents *os.File) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MatchWalker ¶
type MatchWalker struct {
// contains filtered or unexported fields
}
MatchWalker walks a directory tree, only calling the wrapped WalkFunc if the path matches
func NewMatchWalker ¶
func NewMatchWalker(patterns []*regexp.Regexp, walkFunc filepath.WalkFunc) *MatchWalker
NewMatchWalker returns a new MatchWalker given a slice of patterns and a filepath.WalkFunc
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 ¶
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.
func (*TarBuilder) VirtualFileWithContents ¶
func (t *TarBuilder) VirtualFileWithContents(relPath string, contents *os.File) error
VirtualFileWithContents creates an entry at relPath with contents from the given file. This can be used to build a virtual directory structure inside the tar archive.