archive

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFormat = errors.New("unknown format")

ErrFormat indicates that encountered an unknown format.

Functions

func Pack

func Pack(w io.Writer, format Format, files ...File) error

Pack creates an archive from File struct.

func PackFromFiles

func PackFromFiles(w io.Writer, format Format, files ...string) error

PackFromFiles creates an archive from files.

func UnpackToFiles

func UnpackToFiles(r io.Reader, dest string) error

UnpackToFiles decompresses an archive to files.

Types

type File

type File struct {
	Name  string
	Body  []byte
	IsDir bool
}

File struct contains bytes body and the provided name field.

func Unpack

func Unpack(r io.Reader) ([]File, error)

Unpack decompresses an archive to File struct.

type Format

type Format int

Format represents the archive format.

const (
	// ZIP format
	ZIP Format = iota
	// TAR format
	TAR
)

func IsArchive

func IsArchive(b []byte) (bool, Format)

IsArchive tests b is an archive file or not, if ok also return its format.

Jump to

Keyboard shortcuts

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