archive

package
v1.3.24 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 21 Imported by: 1

Documentation

Overview

Package archive: write, read, copy, append, list primitives across all supported formats

  • Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.

Package archive: write, read, copy, append, list primitives across all supported formats

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package archive: write, read, copy, append, list primitives across all supported formats

  • Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.

Package archive: write, read, copy, append, list primitives across all supported formats

  • Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.

Package archive: write, read, copy, append, list primitives across all supported formats

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package archive: write, read, copy, append, list primitives across all supported formats

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package archive: write, read, copy, append, list primitives across all supported formats

  • Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.

Index

Constants

View Source
const (
	ExtTar    = ".tar"
	ExtTgz    = ".tgz"
	ExtTarGz  = ".tar.gz"
	ExtZip    = ".zip"
	ExtTarLz4 = ".tar.lz4"
)

supported archive types (file extensions); see also archExts in cmd/cli/cli/const.go NOTE: when adding/removing formats - update:

  • FileExtensions
  • allMagics
  • ext/dsort/shard/rw.go
View Source
const TarBlockSize = 512 // Size of each block in a tar stream

Variables

View Source
var ErrTarIsEmpty = errors.New("tar is empty")
View Source
var FileExtensions = [...]string{ExtTar, ExtTgz, ExtTarGz, ExtZip, ExtTarLz4}
View Source
var MatchMode = [...]string{
	"regexp",
	"prefix",
	"suffix",
	"substr",
	"wdskey",
}

Functions

func EqExt added in v1.3.19

func EqExt(ext1, ext2 string) bool

func IsErrUnknownFileExt

func IsErrUnknownFileExt(err error) bool

func IsErrUnknownMime

func IsErrUnknownMime(err error) bool

func Mime

func Mime(mime, filename string) (string, error)

func MimeFQN

func MimeFQN(smm *memsys.MMSA, mime, archname string) (m string, err error)

NOTE: - on purpose redundant vs the above - not to open file if can be avoided - convention: caller may pass nil `smm` _not_ to spend time (usage: listing and reading)

func MimeFile

func MimeFile(file cos.LomReader, smm *memsys.MMSA, mime, archname string) (m string, err error)

NOTE convention: caller may pass nil `smm` _not_ to spend time (usage: listing and reading)

func OpenTarForAppend added in v1.3.24

func OpenTarForAppend(cname, workFQN string) (rwfh *os.File, tarFormat tar.Format, offset int64, err error)

func SetTarHeader

func SetTarHeader(hdr any)

func Strict

func Strict(mime, filename string) (m string, err error)

motivation: prevent from creating archives with non-standard extensions

func ValidateMatchMode added in v1.3.23

func ValidateMatchMode(mmode string) (_ string, err error)

Types

type ArchRCB added in v1.3.23

type ArchRCB interface {
	Call(filename string, reader cos.ReadCloseSizer, hdr any) (bool, error)
}

to use, construct (`NewReader`) and iterate (`RangeUntil`) (all supported formats) simple/single selection is also supported (`ReadOne`)

type Entry

type Entry struct {
	Name string
	Size int64 // uncompressed size
}

archived file entry

func List

func List(fqn string) ([]*Entry, error)

type ErrMatchMode added in v1.3.23

type ErrMatchMode struct {
	// contains filtered or unexported fields
}

func (*ErrMatchMode) Error added in v1.3.23

func (e *ErrMatchMode) Error() string

type ErrUnknownFileExt

type ErrUnknownFileExt struct {
	// contains filtered or unexported fields
}

assorted errors

func NewErrUnknownFileExt

func NewErrUnknownFileExt(filename, detail string) (e *ErrUnknownFileExt)

func (*ErrUnknownFileExt) Error

func (e *ErrUnknownFileExt) Error() (s string)

type ErrUnknownMime

type ErrUnknownMime struct {
	// contains filtered or unexported fields
}

assorted errors

func NewErrUnknownMime

func NewErrUnknownMime(d string) *ErrUnknownMime

func (*ErrUnknownMime) Error

func (e *ErrUnknownMime) Error() string

type HeaderCallback

type HeaderCallback func(any)

type Opts

type Opts struct {
	CB        HeaderCallback
	TarFormat tar.Format
	Serialize bool
}

type Reader

type Reader interface {
	// - call rcb (reader's callback) with each matching archived file, where:
	//   - `regex` is the matching string that gets interpreted according
	//      to one of the enumerated "matching modes" (see MatchMode);
	//   - an empty `regex` is just another case of cos.EmptyMatchAll - i.e., matches all archived files
	// - stop upon EOF, or when rcb returns true (ie., stop) or any error
	ReadUntil(rcb ArchRCB, regex, mmode string) error

	// simple/single selection of a given archived filename (full path)
	ReadOne(filename string) (cos.ReadCloseSizer, error)
	// contains filtered or unexported methods
}

to use, construct (`NewReader`) and iterate (`RangeUntil`) (all supported formats) simple/single selection is also supported (`ReadOne`)

func NewReader

func NewReader(mime string, fh io.Reader, size ...int64) (ar Reader, err error)

type Writer

type Writer interface {
	// Init specific writer
	Write(nameInArch string, oah cos.OAH, reader io.Reader) error
	// Close, cleanup
	Fini()
	// Copy arch, with potential subsequent APPEND
	Copy(src io.Reader, size ...int64) error
	// contains filtered or unexported methods
}

func NewWriter

func NewWriter(mime string, w io.Writer, cksum *cos.CksumHashSize, opts *Opts) (aw Writer)

calls init() -> open(),alloc()

Jump to

Keyboard shortcuts

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