Documentation
¶
Overview ¶
Package archive provides helper functions for dealing with archive files.
Index ¶
- Variables
- func DecompressStream(archive io.Reader) (io.ReadCloser, error)
- func FileInfoHeader(name string, fi os.FileInfo, link string) (*tar.Header, error)
- func IsArchivePath(path string) bool
- func Unpack(ctx context.Context, decompressedArchive io.Reader, dest string, ...) error
- func Untar(ctx context.Context, tarArchive io.Reader, dest string, options *TarOptions) error
- type TarOptions
- type Tarballer
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotDirectory = errors.New("not a directory") ErrDirNotExists = errors.New("no such directory") ErrCannotCopyDir = errors.New("cannot copy directory") ErrInvalidCopySource = errors.New("invalid copy source content") )
Errors used or returned by this file.
Functions ¶
func DecompressStream ¶
func DecompressStream(archive io.Reader) (io.ReadCloser, error)
DecompressStream decompresses the archive and returns a ReaderCloser with the decompressed archive.
func FileInfoHeader ¶
FileInfoHeader creates a populated Header from fi.
func IsArchivePath ¶
IsArchivePath checks if the (possibly compressed) file at the given path starts with a tar file header.
Types ¶
type TarOptions ¶
type Tarballer ¶
type Tarballer struct {
FileInfoReporter func(fs.FileInfo)
// contains filtered or unexported fields
}
Tarballer is a lower-level interface to TarWithOptions which gives the caller control over which goroutine the archiving operation executes on.
func NewTarballer ¶
func NewTarballer(ctx context.Context, srcPath string, options *TarOptions, reporterFn func(fs.FileInfo)) (*Tarballer, error)
NewTarballer constructs a new tarballer. The arguments are the same as for TarWithOptions.
func Tar ¶
func Tar(ctx context.Context, srcPath string, options *TarOptions, reporterFn func(fs.FileInfo)) (*Tarballer, error)
Tar creates an archive from the directory at `path`, only including files whose relative paths are included in `options.IncludeFiles` (if non-nil) or not in `options.ExcludePatterns`.
func (*Tarballer) Do ¶
func (t *Tarballer) Do()
Do performs the archiving operation in the background. The resulting archive can be read from t.Reader(). Do should only be called once on each Tarballer instance.
func (*Tarballer) Reader ¶
func (t *Tarballer) Reader() io.ReadCloser
Reader returns the reader for the created archive.
func (*Tarballer) UnpackedSize ¶
UnpackedSize returns the total size of the files added to the archive.