archivelib

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package archivelib expands archive blobs into their member listing and opens individual members, from any seekable stream. It is client-side only — the filehost stays a pure content-addressed byte store and never parses archives. archivelib deliberately does not import the client package (which maps Kind to a tie-type), so it can be reused by the FUSE mounts and the CLI without an import cycle.

Archive access is backed by github.com/mholt/archives, the same library the imgview/tieview viewer uses, so tie recognizes the same formats (zip, tar, rar, 7z, cbr, ...) and behaves identically to the viewer's local-archive path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(r Stream, name string) (io.ReadCloser, error)

Open returns a reader over a single member's decompressed bytes. The returned stream is forward-only; callers needing random access must copy it to a seekable file first.

Types

type Kind

type Kind int

Kind is the neutral media category of a member, mirroring the file tie-types without depending on the client package.

const (
	Unknown Kind = iota
	Image
	Audio
	Video
	Document
)

func ModalKind

func ModalKind(members []Member) Kind

ModalKind returns the most common recognized member kind, ignoring Unknown members. An album of tracks with one cover image resolves to Audio; a scan dump of images resolves to Image. Returns Unknown when nothing is recognized.

type Member

type Member struct {
	Name string
	Size int64
	Head []byte
	Kind Kind
}

Member is one file entry inside an archive.

func List

func List(r Stream) ([]Member, error)

List enumerates the non-directory members of an archive, sniffing each member's leading bytes to classify it. Members that fail to open are skipped.

type Stream

type Stream = archives.ReaderAtSeeker

Stream is the input an archive is read from: a seekable, random-access byte source (os.File, bytes.Reader, io.SectionReader all satisfy it). mholt's FileSystem needs io.ReaderAt+io.Seeker for safe concurrent access and io.Reader for format sniffing.

Jump to

Keyboard shortcuts

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