archive

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package archive is a utility that allows for simple archiving of files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Archive

func Archive[A Archiver](t errs.Testing, w io.Writer, files ...FileHeader)

Archive is responsible for the actual archiving.

Types

type Archiver

type Archiver interface {
	// New produces a new instance of this method.
	New(errs.Testing, io.Writer) Writer
}

Archiver is implemented by a compression method.

type Entry

type Entry[C any] struct {
	Name    string
	Time    time.Time
	Content C
}

Entry is a file or folder in the archive. Files are defined by `Entry[[]byte]` or `Entry[io.Reader]`. Folders are defined by `Entry[[]FileHeader]`.

func (Entry[C]) EntryContent

func (bce Entry[C]) EntryContent() C

func (Entry[C]) EntryName

func (bce Entry[C]) EntryName() string

func (Entry[C]) EntryTime

func (bce Entry[C]) EntryTime() time.Time

type FileHeader

type FileHeader interface {
	EntryName() string
	EntryTime() time.Time
	// contains filtered or unexported methods
}

FileHeader is an interface for all files in the archive.

type Tar

type Tar struct{}

Tar allows writing .tar archives.

func (Tar) New

func (Tar) New(t errs.Testing, w io.Writer) Writer

type Writer

type Writer interface {
	io.Closer
	WriteFile(errs.Testing, FileHeader, io.Reader)
	WriteDir(errs.Testing, FileHeader)
}

Writer represents the archive being written.

type Zip

type Zip struct{}

Zip allows writing .zip archives.

func (Zip) New

func (Zip) New(t errs.Testing, w io.Writer) Writer

Jump to

Keyboard shortcuts

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