extraction

package
v0.0.0-...-5f25c38 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 18 Imported by: 0

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) Choose

func (b *BinaryChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

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

func NewExtractor(fs vfs.FS, filename string, tool string, chooser Chooser) Extractor

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) Choose

func (gc *GlobChooser) Choose(name string, _ bool, _ fs.FileMode) (bool, bool)

func (*GlobChooser) String

func (gc *GlobChooser) String() string

type LiteralFileChooser

type LiteralFileChooser struct {
	File string
}

LiteralFileChooser selects files with the name 'File'.

func (*LiteralFileChooser) Choose

func (lf *LiteralFileChooser) Choose(name string, _ bool, _ fs.FileMode) (bool, bool)

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 NewSingleFileExtractor(name string, rename string, decompress func(r io.Reader) (io.Reader, error), fs interface{}) *SingleFileExtractor

func (*SingleFileExtractor) Extract

func (sf *SingleFileExtractor) Extract(data []byte, _ bool) (ExtractedFile, []ExtractedFile, error)

Jump to

Keyboard shortcuts

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