archive

package module
v0.0.0-...-3a6449e Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: MPL-2.0 Imports: 16 Imported by: 4

README

archive

Package archive contains traversal utilities for ZIP and tar archives with gzip, bzip2, xz, and LZ4 compression.

Clients include andrewarchi/browser and andrewarchi/urlhero.

License

This project is made available under the Mozilla Public License.

Documentation

Overview

Package archive contains traversal utilities for ZIP and tar archives with gzip, bzip2, xz, and LZ4 compression.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewXZReader

func NewXZReader(r io.Reader) (io.ReadCloser, error)

NewXZReader returns a reader that decompresses XZ data using system xz, if in PATH, otherwise falling back to a slower Go implementation.

func OpenSingleFileZip

func OpenSingleFileZip(filename string) (io.ReadCloser, string, error)

OpenSingleFileZip opens a zip containing a single file for reading and returns the filename of the contained file.

func Walk

func Walk(r io.Reader, filename string, walk WalkFunc) error

Walk traverses an archive from an io.Reader and executes the given walk function on each file. Supported archive and compression formats: ZIP, tar, gzip, bzip2, xz, and LZ4.

func WalkFile

func WalkFile(filename string, walk WalkFunc) error

WalkFile traverses an archive from a file and executes the given walk function on each file. Supported archive and compression formats: ZIP, tar, gzip, bzip2, xz, and LZ4.

func WalkTar

func WalkTar(r io.Reader, filename string, walk WalkFunc) error

WalkTar traverses a tar archive from an io.Reader and executes the given walk function on each file.

func WalkTarFile

func WalkTarFile(filename string, walk WalkFunc) error

WalkTarFile traverses a tar archive from a file and executes the given walk function on each file.

func WalkZip

func WalkZip(r io.ReaderAt, size int64, filename string, walk WalkFunc) error

WalkZip traverses a ZIP archive from an io.ReaderAt and executes the given walk function on each file.

func WalkZipFile

func WalkZipFile(filename string, walk WalkFunc) error

WalkZipFile traverses a ZIP archive from a file and executes the given walk function on each file.

Types

type File

type File interface {
	Name() string
	Open() (io.ReadCloser, error)
	FileInfo() os.FileInfo
}

File exposes a common interface for files in an archive.

type WalkFunc

type WalkFunc func(File) error

WalkFunc is the type of function that is called for each file visited.

func Extract

func Extract(filename, dir string) WalkFunc

Extract returns a WalkFunc that extracts the files in an archive to the given directory.

Jump to

Keyboard shortcuts

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