unarchiver

package
v0.0.0-...-7426b64 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package unarchiver provides a method to unarchive tar.gz or zip archives with progress bar feedback Currently, this implementation copies a lot of methods that are internal to the ActiveState/archiver dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtractNotifier

type ExtractNotifier func(fileName string, size int64, isDir bool)

ExtractNotifier gets called when a new file has been extracted from the archive

type SingleUnarchiver

type SingleUnarchiver interface {
	archiver.Reader

	// ExtractNext extracts the next file in the archive
	ExtractNext(destination string) (f archiver.File, err error)

	// CheckExt checks that the file extension is appropriate for the archive
	CheckExt(archiveName string) error

	// Ext returns a valid file name extension for this archiver
	Ext() string
}

SingleUnarchiver is an interface for an unarchiver that can unpack the next file It extends the existing archiver.Reader with a method to extract a single file from the archive

type TarGzArchive

type TarGzArchive struct {
	*archiver.TarGz
}

TarGzArchive is an extension of an TarGz archiver implementing an unarchive method with progress feedback

func (*TarGzArchive) Ext

func (ar *TarGzArchive) Ext() string

func (*TarGzArchive) ExtractNext

func (ar *TarGzArchive) ExtractNext(destination string) (f archiver.File, err error)

ExtractNext extracts the next file to destination

func (*TarGzArchive) GetExtractedSize

func (ar *TarGzArchive) GetExtractedSize(source string) (int, error)

GetExtractedSize returns the size of the extracted summed up files in the archive

type TarGzBlob

type TarGzBlob struct {
	// contains filtered or unexported fields
}

func NewTarGzBlob

func NewTarGzBlob(blob []byte) *TarGzBlob

func (*TarGzBlob) Unarchive

func (t *TarGzBlob) Unarchive(dest string) error

type Unarchiver

type Unarchiver struct {
	// contains filtered or unexported fields
}

Unarchiver wraps an implementation of an unarchiver that can unpack one file at a time.

func NewTarGz

func NewTarGz() Unarchiver

NewTarGz initializes a new TarGzArchiver

func NewZip

func NewZip() Unarchiver

NewZip initializes a new ZipArchive

func (*Unarchiver) CheckExt

func (ua *Unarchiver) CheckExt(archiveName string) error

CheckExt checks that the file extension is appropriate for the given unarchiver

func (*Unarchiver) Ext

func (ua *Unarchiver) Ext() string

func (*Unarchiver) PrepareUnpacking

func (ua *Unarchiver) PrepareUnpacking(source, destination string) (archiveFile *os.File, fileSize int64, err error)

PrepareUnpacking prepares the destination directory and the archive for unpacking Returns the opened file and its size

func (*Unarchiver) SetNotifier

func (ua *Unarchiver) SetNotifier(cb ExtractNotifier)

SetNotifier sets the notification function to be called after extracting a file

func (*Unarchiver) Unarchive

func (ua *Unarchiver) Unarchive(archiveStream io.Reader, archiveSize int64, destination string) (err error)

Unarchive unarchives an archive file ` and unpacks it in `destination`

type ZipArchive

type ZipArchive struct {
	*archiver.Zip
}

ZipArchive is an extension of an Zip archiver implementing an unarchive method with progress feedback

func (*ZipArchive) Ext

func (z *ZipArchive) Ext() string

func (*ZipArchive) ExtractNext

func (z *ZipArchive) ExtractNext(destination string) (f archiver.File, err error)

ExtractNext extracts the next file to destination

type ZipBlob

type ZipBlob struct {
	// contains filtered or unexported fields
}

func NewZipBlob

func NewZipBlob(blob []byte) *ZipBlob

func (*ZipBlob) Unarchive

func (z *ZipBlob) Unarchive(dest string) error

Jump to

Keyboard shortcuts

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