archive

package
v0.0.0-...-eaaab9e Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package archive provides common types and functions for archive processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canonicalize

func Canonicalize(dst io.Writer, src io.Reader, f Format) error

Canonicalize selects and applies the canonicalization routine for the given archive format.

func CanonicalizeTar

func CanonicalizeTar(tr *tar.Reader, tw *tar.Writer) error

CanonicalizeTar strips volatile metadata and re-writes the provided archive in a canonical form.

func CanonicalizeZip

func CanonicalizeZip(zr *zip.Reader, zw *zip.Writer) error

CanonicalizeZip strips volatile metadata and rewrites the provided archive in a canonical form.

func ExtractTar

func ExtractTar(tr *tar.Reader, fs billy.Filesystem, opt ExtractOptions) error

ExtractTar writes the contents of a tar to a filesystem.

Types

type ContentSummary

type ContentSummary struct {
	Files      []string
	FileHashes []string
	CRLFCount  int
}

ContentSummary is a summary of rebuild-relevant features of an archive.

func NewContentSummary

func NewContentSummary(src io.Reader, f Format) (*ContentSummary, error)

NewContentSummary constructs a ContentSummary for the given archive format.

func NewContentSummaryFromTar

func NewContentSummaryFromTar(tr *tar.Reader) (*ContentSummary, error)

NewContentSummaryFromTar returns a ContentSummary for a tar archive.

func NewContentSummaryFromZip

func NewContentSummaryFromZip(zr *zip.Reader) (*ContentSummary, error)

NewContentSummaryFromZip returns a ContentSummary for a zip archive.

func (*ContentSummary) Diff

func (cs *ContentSummary) Diff(other *ContentSummary) (leftOnly, diffs, rightOnly []string)

Diff returns the files that are only in this summary, the files that are in both summaries but have different hashes, and the files that are only in the other summary.

type ExtractOptions

type ExtractOptions struct {
	// SubDir is a directory within the TAR to extract relative to the provided filesystem.
	SubDir string
}

ExtractOptions provides options modifying ExtractTar behavior.

type Format

type Format int

Format represents the archive types of packages.

const (
	UnknownFormat Format = iota
	TarGzFormat
	TarFormat
	ZipFormat
	RawFormat
)

ArchiveType constants specify the type of archive of a file/target.

type TarEntry

type TarEntry struct {
	*tar.Header
	Body []byte
}

TarEntry represents an entry in a tar archive.

func (TarEntry) WriteTo

func (e TarEntry) WriteTo(tw *tar.Writer) error

WriteTo writes the TarEntry to a tar writer.

type ZipEntry

type ZipEntry struct {
	*zip.FileHeader
	Body []byte
}

ZipEntry represents an entry in a zip archive.

func (ZipEntry) WriteTo

func (e ZipEntry) WriteTo(zw *zip.Writer) error

WriteTo writes the ZipEntry to a zip writer.

Jump to

Keyboard shortcuts

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