archive

package
v1.3.19 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 18 Imported by: 0

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-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-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-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.

Index

Constants

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

supported archive types (file extensions); ref cmd/cli/cli/const.go archExts

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, ExtTarTgz, ExtZip, ExtTarLz4}

NOTE: when adding/removing check `allMagic` as well

Functions

func GetReader

func GetReader(fh *os.File, archname, filename, mime string, size int64) (cos.ReadCloseSizer, error)

func Init

func Init(f feat.Flags)

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 *os.File, 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 OpenTarSeekEnd

func OpenTarSeekEnd(cname, workFQN string) (rwfh *os.File, err error)

Opens TAR and uses its reader's Next() to skip to the position right _after_ the last file in the TAR (padding bytes including).

Background: TAR file is padded with one or more 512-byte blocks of zero bytes. The blocks must be overwritten, otherwise newly added files won't be accessible. Different TAR formats (such as `ustar`, `pax` and `GNU`) write different number of zero blocks.

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

Types

type Entry

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

archived file entry

func List

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

type ErrUnknownFileExt

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

assorted errors

func NewErrUnknownFileExt

func NewErrUnknownFileExt(d string) *ErrUnknownFileExt

func (*ErrUnknownFileExt) Error

func (e *ErrUnknownFileExt) Error() 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
	Serialize bool
}

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