Documentation
¶
Overview ¶
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-2025, 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-2025, NVIDIA CORPORATION. All rights reserved.
Package archive: write, read, copy, append, list primitives across all supported formats
- Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
Package archive: write, read, copy, append, list primitives across all supported formats
- Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
Package archive: write, read, copy, append, list primitives across all supported formats
- Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
Index ¶
- Constants
- Variables
- func ContentTypeFromExt(ext string) string
- func DetectCompression(r io.ReaderAt) (string, error)
- func EqExt(ext1, ext2 string) bool
- func ExtFromContentType(ct string) string
- func IsErrUnknownFileExt(err error) bool
- func IsErrUnknownMime(err error) bool
- func Mime(mime, filename string) (string, error)
- func MimeFQN(smm *memsys.MMSA, mime, archname string) (m string, err error)
- func MimeFile(lh cos.LomReader, smm *memsys.MMSA, mime, archname string) (m string, err error)
- func OpenTarForAppend(cname, workFQN string) (rwfh *os.File, tarFormat tar.Format, offset int64, err error)
- func SetTarHeader(hdr any)
- func SplitAtExtension(path string) (shardName, fileName string)
- func Strict(mime, filename string) (m string, err error)
- func ValidateMatchMode(mmode string) (_ string, err error)
- type ArchRCB
- type Drain
- type Entry
- type ErrMatchMode
- type HeaderCallback
- type Opts
- type Reader
- type Writer
Constants ¶
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
const ( ExtGz = ".gz" ExtLz4 = ".lz4" )
compression formats - not necessarily compressed TAR
const TarBlockSize = 512 // Size of each block in a tar stream
Variables ¶
var ErrTarIsEmpty = errors.New("tar is empty")
var MatchMode = [...]string{
"regexp",
"prefix",
"suffix",
"substr",
"wdskey",
}
Functions ¶
func ContentTypeFromExt ¶ added in v1.4.1
func DetectCompression ¶ added in v1.3.30
inspect the first bytes of r and return a compression extension (ExtGz, ExtLz4); an empty `ext` indicates plain-text (or rather: no compression)
func ExtFromContentType ¶ added in v1.4.1
func IsErrUnknownFileExt ¶
func IsErrUnknownMime ¶
func MimeFQN ¶
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 OpenTarForAppend ¶ added in v1.3.24
func SetTarHeader ¶
func SetTarHeader(hdr any)
func SplitAtExtension ¶ added in v1.4.1
func ValidateMatchMode ¶ added in v1.3.23
Types ¶
type ArchRCB ¶ added in v1.3.23
to use, construct (`NewReader`) and iterate (`RangeUntil`) (all supported formats) simple/single selection is also supported (`ReadOne`)
type Drain ¶ added in v1.4.1
type Drain struct {
// contains filtered or unexported fields
}
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 HeaderCallback ¶
type HeaderCallback func(any)
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`)
type Writer ¶
type Writer interface {
// Init specific writer
Write(nameInArch string, oah cos.OAH, reader io.Reader) error
// Close, cleanup
Fini() error
// Copy arch, with potential subsequent APPEND
Copy(src io.Reader, size ...int64) error
Flush() error
// contains filtered or unexported methods
}
TODO: consider adding Size() for the number of bytes already written to the underlying writer - compressed bytes for compressed formats (note that cos.CksumHashSize has size)