Documentation ¶
Index ¶
- Variables
- func Resolve(r io.Reader, targetPath string, options ...Option) error
- func Walk(path string, walkFunc WalkFunc) error
- type Algorithm
- type Composer
- type Entry
- func (e *Entry) Group() string
- func (e *Entry) GroupID() uint32
- func (e *Entry) IsDir() bool
- func (e *Entry) Linkname() string
- func (e *Entry) ModTime() time.Time
- func (e *Entry) Mode() os.FileMode
- func (e *Entry) Name() string
- func (e *Entry) Owner() string
- func (e *Entry) OwnerID() uint32
- func (e *Entry) Size() int64
- func (e *Entry) Sys() interface{}
- type Level
- type Option
- type Resolver
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Resolve ¶
Resolve takes a tarball (optionally compressed) from r and extracts it to targetPath with options. The leading slashes of the files are trimmed and path traversal is forbidden.
func Walk ¶
Walk is a walking function similar to filepath.Walk, but differs in these aspects:
- It takes WalkFunc instead of filepath.WalkFunc.
- The passed-in path must be a directory.
- The error that occurred during walking is directly returned, without passing to WalkFunc.
- Lots of magic targeting *nix systems. See the comments for details.
Types ¶
type Composer ¶
type Composer struct {
// contains filtered or unexported fields
}
Composer is a tarball creation context.
func NewComposer ¶
NewComposer creates a Composer with options, writing the tarball to w.
func (*Composer) Add ¶
Add adds a path to the tarball. The path argument is the root path of files being added. If it's a file, only the file is added. The paths of all files are trimmed from the prefix filepath.Dir(path). The base argument is prepended to the paths of all files using filepath.Join. In other words, if you call Add("/a/b/c", "d/e"), all files in /a/b/c are added as d/e/c/... including /a/b/c itself.
type Entry ¶ added in v0.0.3
type Entry struct {
// contains filtered or unexported fields
}
Entry represents a file, used in WalkFunc, specialized for tar headers.
type Option ¶
type Option func(i private) error
func WithCompression ¶
WithCompression provides the compression algorithm of tar creation and extraction.
func WithReadAhead ¶
WithReadAhead specifies the maximum number of files to be read ahead.
func WithThread ¶
WithThread specifies the worker number during extraction.
func WithThreshold ¶
WithThreshold specifies the threshold size in bytes of buffered files during extraction.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is the context used when a tarball is being extracted. It shouldn't be used directly. Use Resolve instead.
type WalkFunc ¶
type WalkFunc func(path string, entry *Entry, r io.ReadCloser) error
WalkFunc is the type of the function called by Walk to visit each file or directory. The path argument is the absolute path of the current file. The linkName argument is the link target if this file is a symlink, otherwise empty. The entry argument is an Entry struct about this file. The r argument is the reader of this file, if it's a regular one. It must be closed if it's not nil.