archive

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 32 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package archive reads archive / container formats — tar (and compressed tar), zip, 7z, rar, cpio, asar, rpm, deb and OCI image layouts — and exposes a uniform list/open surface over them. Formats are identified by content, not filename extension (see Detect), so a misnamed file still opens correctly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeAXML added in v0.6.0

func DecodeAXML(data []byte) (string, error)

DecodeAXML converts binary Android XML into indented-free text XML.

func Detect

func Detect(path string) (string, error)

Detect classifies an archive by its header, returning a format name ("tar", "zip", "asar", "rpm", ...) or "" when the file is not a recognized archive.

func IsOCILayout

func IsOCILayout(path string) bool

IsOCILayout reports whether path is a directory containing an OCI image layout (an oci-layout file plus an index.json). An OCI layout is read through the same archive pipeline as docker save archives, so it is a directory rather than a disk image. The single-file variant (oci-archive, e.g. `podman save --format oci` or a flatpak bundle) is a tar handled by openOCITar.

Types

type Archive

type Archive interface {
	List() ([]Entry, error)
	Open(name string) (io.ReadCloser, int64, error)
}

Archive is an opened archive: List enumerates its members, Open streams one member's contents.

func Open

func Open(path string) (Archive, error)

Open opens an archive, dispatching on content rather than filename extension.

type Entry

type Entry struct {
	Name     string
	Size     int64
	Kind     fsview.Kind
	Mode     int64 // permission + setuid/setgid/sticky bits (tar-style low 12 bits)
	ModTime  time.Time
	UID      int
	GID      int
	Uname    string
	Gname    string
	Linkname string
	Devmajor int64 // device major number, only meaningful for device kinds
	Devminor int64 // device minor number, only meaningful for device kinds
}

Entry describes one member of an archive.

type Sequential added in v0.6.2

type Sequential interface {
	NewSequentialReader() (SequentialReader, error)
}

Sequential is implemented by archives readable in a single sequential pass.

type SequentialReader added in v0.6.2

type SequentialReader interface {
	Next() (name string, size int64, r io.Reader, err error)
	Close()
}

SequentialReader walks the entries of an archive in one pass over the underlying stream. It exists for formats whose members are expensive to reach by name (a compressed tar must be decompressed from the start for every Open), so callers that need many entries — image layer merging, for instance — can read them all in a single pass.

Next returns the name and size of the next entry plus a reader over its data. The reader is only valid until the following Next call; callers that do not consume an entry in full can still call Next, which discards the remainder.

func SequentialOf added in v0.6.2

func SequentialOf(a Archive) SequentialReader

SequentialOf returns a sequential reader for an archive, or nil when the archive does not support single-pass reading.

Jump to

Keyboard shortcuts

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