Documentation
¶
Index ¶
Constants ¶
const ( TarGzip Type = "tar.gz" TarBzip = "tar.bz2" TarXz = "tar.xz" Tar = "tar" Zip = "zip" )
Variables ¶
var ( ErrArchiveTypeNotSupported = errors.New("archive type not supported") ErrArchiveFileNotFound = errors.New("archive file not found") )
Functions ¶
This section is empty.
Types ¶
type Archive ¶
type Archive struct { // Type of Archive Type Type // Path of Archive file Path string // contains filtered or unexported fields }
func Open ¶
Open opens an archive file and returns an Archive struct. It takes a Type and a path to the archive file as its parameters. The function returns an Archive struct and an error, if any.
func OpenFS ¶
func OpenFS(filesystem Filesystem, archiveType Type, path string) (*Archive, error)
OpenFS opens an archive file from a given fs.FS and returns an Archive struct. It takes fs.FS, Type and a path to the archive file as its parameters. The function returns an Archive struct and an error, if any.
func (*Archive) Extract ¶
func (a *Archive) Extract(opts ExtractOptions) error
Extract extracts the specified Archive to a specified directory. It takes ExtractOptions as its parameter The function returns an error, if any.
func (*Archive) ExtractBillyFS ¶
func (a *Archive) ExtractBillyFS(filesystem billy.Filesystem, opts ExtractOptions) error
ExtractBillyFS extracts the specified Archive into billy.Filesystem. It takes billy.Filesystem and ExtractOptions as its parameters. The function returns an error, if any.
type ExtractFileOptions ¶
type ExtractFileOptions struct { // Whether to overwrite files if they already exist. Overwrite bool // Perms for output file, default is the permission in the Archive. Perms os.FileMode // Folder to extract Archive to. Folder string // Whether to preserve the file structure in the Archive or not. NotPreserveFileStructure bool }
ExtractFileOptions represents options for extracting an ArchiveFile
type ExtractOptions ¶
type ExtractOptions struct { // Whether to overwrite files if they already exist. Overwrite bool // Folder to extract Archive to. Folder string // Whether to preserve the file structure in the Archive or not. NotPreserveFileStructure bool // Optional regex filter for specific files. Filter *regexp.Regexp }
ExtractOptions represents options for extracting an Archive
type File ¶
type File struct { // Name of file (e.g "test.txt") FileName string // Path of file in archive (e.g "folder/test.txt") Path string // contains filtered or unexported fields }
File represents a file in an archive.
func (*File) Extract ¶
func (f *File) Extract(opts ExtractFileOptions) error
Extract extracts the specified File in the archive to a specified directory. It takes ExtractFileOptions as its parameter. The function returns an error, if any.
func (*File) ExtractBillyFS ¶
func (f *File) ExtractBillyFS(filesystem billy.Filesystem, opts ExtractFileOptions) error
ExtractBillyFS extracts the specified File in the archive into billy.Filesystem. It takes billy.Filesystem and ExtractFileOptions as its parameters. The function returns an error, if any.
type Filesystem ¶
type Filesystem struct {
// contains filtered or unexported fields
}
Filesystem represents a standard interface for filesystems. Currently, supports fs.FS and billy.Filesystem.
func WrapBillyFS ¶
func WrapBillyFS(filesystem billy.Filesystem) Filesystem
WrapBillyFS wraps billy.Filesystem to the Filesystem interface. Returns Filesystem.
func WrapFS ¶
func WrapFS(filesystem fs.FS) Filesystem
WrapFS wraps fs.FS to the Filesystem interface. Returns Filesystem.
func WrapPath ¶
func WrapPath(path string) Filesystem
WrapPath wraps a path to the Filesystem interface. Returns Filesystem.