Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchiveExtractor ¶
type ArchiveExtractor struct { File Chooser Ar archives.ArchiveFunc Decompress archives.DecompressFunc Fs vfs.FS }
func NewArchiveExtractor ¶
func NewArchiveExtractor(file Chooser, ar archives.ArchiveFunc, decompress archives.DecompressFunc, fs interface{}) *ArchiveExtractor
func (*ArchiveExtractor) Extract ¶
func (a *ArchiveExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)
type BinaryChooser ¶
type BinaryChooser struct {
Tool string
}
A BinaryChooser selects executable files. If the executable file has the name 'Tool' it is considered a direct match. If the file is only executable, it is a possible match.
func (*BinaryChooser) String ¶
func (b *BinaryChooser) String() string
type Chooser ¶
type Chooser interface {
Choose(name string, dir bool, mode fs.FileMode) (direct bool, possible bool)
}
A Chooser selects a file. It may list the file as a direct match (should be immediately extracted if found), or a possible match (only extract if it is the only match, or if the user manually requests it).
type ExtractedFile ¶
type ExtractedFile struct { Name string // name to extract to ArchiveName string // name in archive Extract func(to string) error Dir bool // contains filtered or unexported fields }
An ExtractedFile contains the data, name, and permissions of a file in the archive.
func (ExtractedFile) Mode ¶
func (e ExtractedFile) Mode() fs.FileMode
Mode returns the filemode of the extracted file.
func (ExtractedFile) SetMode ¶
func (e ExtractedFile) SetMode(mode fs.FileMode)
func (ExtractedFile) String ¶
func (e ExtractedFile) String() string
String returns the archive name of this extracted file
type Extractor ¶
type Extractor interface {
Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)
}
An Extractor reads in some archive data and extracts a particular file from it. If there are multiple candidates it returns a list and an error explaining what happened.
func NewExtractor ¶
NewExtractor constructs an extractor for the given archive file using the given chooser. It will construct extractors for files ending in '.tar.gz', '.tar.bz2', '.tar', '.zip'. After these matches, if the file ends with '.gz', '.bz2' it will be decompressed and copied. Other files will simply be copied without any decompression or extraction.
type GlobChooser ¶
type GlobChooser struct {
// contains filtered or unexported fields
}
func NewGlobChooser ¶
func NewGlobChooser(gl string) (*GlobChooser, error)
func (*GlobChooser) String ¶
func (gc *GlobChooser) String() string
type LiteralFileChooser ¶
type LiteralFileChooser struct {
File string
}
LiteralFileChooser selects files with the name 'File'.
func (*LiteralFileChooser) String ¶
func (lf *LiteralFileChooser) String() string
type SingleFileExtractor ¶
type SingleFileExtractor struct { Rename string Name string Decompress func(r io.Reader) (io.Reader, error) Fs vfs.FS }
SingleFileExtractor extracts files called 'Name' after decompressing the file with 'Decompress'.
func NewSingleFileExtractor ¶
func (*SingleFileExtractor) Extract ¶
func (sf *SingleFileExtractor) Extract(data []byte, _ bool) (ExtractedFile, []ExtractedFile, error)