tar

package module
v0.1.76 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: BSD-3-Clause Imports: 40 Imported by: 0

README

Go Advanced TAR Library (with Ratarmount-compatible Indexing)

Go Reference

This library is a highly optimized and advanced drop-in replacement for the Go standard library archive/tar.

It integrates high-speed compression, parallel extraction, and ratarmount-compatible SQLite indexing to enable instant random access within massive archives.

Design Principles & Requirements

This library is built with strict adherence to the following design constraints:

  • 100% Pure Go (Zero CGO): The entire library is written in pure Go. It cross-compiles natively and seamlessly to any target platform (Linux, macOS, Windows, FreeBSD, etc.) and architecture (amd64, arm64, 386, etc.) without requiring external C libraries or a GCC toolchain.
  • Maximum Code Reuse: Instead of reinventing decompression and archiving from scratch, the library maximizes the reuse of existing industry-standard code. It extends Go's native archive/tar and klauspost/compress to leverage their proven performance, safety, and stability.
  • True O(1) Random Access: Unlike standard sequential readers, this library provides true random access to compressed streams.
    • ZSTD (.tar.zst): Employs an O(1) fast path by jumping directly to byte-aligned, independent ZSTD frame boundaries stored in the index database.
    • GZIP (.tar.gz): Employs an O(1) fast path by parsing binary GZIDX metadata, recovering the 32KB sliding window (dictionary) via flate.NewReaderDict, and using a bit-shifting reader (bitShiftingReader) to align the unaligned DEFLATE bitstream.
  • Industrial Cache Compatibility: The indexing architecture and SQLite database schema are binary-compatible with the industrial standards used by ratarmount and zran (GZIDX). Index databases generated by the Python-based ratarmount can be natively opened and used by this Go library in O(1) time, and vice versa.

Key Features

  • Drop-in Compatibility: 100% compatible with the archive/tar API. You can seamlessly replace your existing archive/tar imports with github.com/unxed/tar.
  • High Performance: Uses klauspost/compress for highly-parallelized ZStandard and optimized Gzip compression streams.
  • Broad Compression Support: Built-in automatic format detection (magic bytes) for GZIP, BZIP2, XZ, and ZSTD.
  • Parallel Extraction: Reads TAR sequentially but delegates filesystem writes, file creations, and metadata restoration (chmod/chown) to a parallel worker pool.
  • In-place Updates (Updater): Truncates existing TAR EOF zero blocks to allow appending new files without full archive rewrite.
  • ratarmount-compatible Indexing & Random Access (fs.FS):
    • Indexes .tar or compressed .tar.* archives on the fly into an SQLite database with a schema identical to ratarmount.
    • Exposes the archive as a standard Go fs.FS interface.
    • Facilitates O(1) random-access file reading for uncompressed .tar archives via io.SectionReader.
    • Automatically synthesizes missing parent folders on the fly.
    • Supports F4 Embedded TAR Index Format (F4SS) which bundles the index directly inside .tar, .tar.gz, or .tar.zst archives natively and compliantly. Read f4tar.md for details.
  • Unix Properties Preservation: Transparently preserves and restores Symlinks, Hardlinks, Unix permissions, UID/GID (numeric & string), timestamps, and special files (Devices, FIFOs).
  • NTFS & Windows Compatibility: Supports reading, writing, and restoring Windows Security Descriptors (NTFS ACLs) via PAX extended headers, alongside physical pre-allocation to prevent file fragmentation on NTFS.
  • Safe Extraction and Sanitization: Implements automatic path verification to block symlink directory traversal attacks (such as Tar Slip), sanitizes Zone.Identifier (Mark of the Web) streams, and safely cleans up partial files on errors unless configured otherwise.
  • POSIX Extended Attributes (PAX xattrs): Stores and restores complete extended attributes (including SELinux contexts and POSIX ACLs) using standard PAX records with SCHILY.xattr.* and LIBARCHIVE.xattr.* prefixes.
  • Windows Security Descriptors (PAX MSWINDOWS.raw_sd): Encodes raw Windows Security Descriptors (NTFS ACLs) as Base64 strings under the standard PAX record MSWINDOWS.raw_sd. This allows cross-platform preservation of Windows security settings.

Usage

1. Standard Drop-in Usage

Simply replace the import path.

import "github.com/unxed/tar"

// Use exactly like the standard library
r, err := tar.OpenReader("archive.tar.gz")
if err != nil {
	log.Fatal(err)
}
defer r.Close()
2. High-Speed Random Access via fs.FS

Generate an SQLite index once and enjoy O(1) random access reads (uncompressed and indexed ZSTD/GZIP) and full io/fs compatibility.

package main

import (
	"io/fs"
	"log"

	"github.com/unxed/tar"
)

func main() {
	// Automatically generates index.sqlite on first run if missing
	tfs, err := tar.NewFS("archive.tar", "index.sqlite")
	if err != nil {
		log.Fatal(err)
	}
	defer tfs.Close()

	// Perform random-access ReadFile (O(1) seek)
	data, err := fs.ReadFile(tfs, "folder/file.txt")
	if err != nil {
		log.Fatal(err)
	}
	log.Println("File contents:", string(data))
}
3. Concurrent Extraction
e, err := tar.NewExtractor("archive.tar.gz", "/path/to/dst", tar.WithExtractorConcurrency(8))
if err != nil {
	log.Fatal(err)
}
defer e.Close()

if err := e.Extract(context.Background()); err != nil {
	log.Fatal(err)
}
4. Append files to TAR
f, err := os.OpenFile("archive.tar", os.O_RDWR, 0644)
if err != nil {
	log.Fatal(err)
}
defer f.Close()

updater, err := tar.NewUpdater(f, tar.APPEND_MODE_OVERWRITE)
if err != nil {
	log.Fatal(err)
}

err = updater.Append("newfile.txt", 4, []byte("data"))
if err != nil {
	log.Fatal(err)
}
updater.Close()

Pluggable Compression Architecture

This library features a modular, pluggable compression registry. If you want to enable true $O(1)$ random-access seeking for custom decompressors (e.g., custom GZIP or BZIP2 decoders), you can register them by implementing the following pure-Go interfaces:

// BlockOffsetImporter allows block-based decompressors (like ZSTD or BZIP2)
// to resume decompression from a specific byte or bit-aligned block boundary.
type BlockOffsetImporter interface {
	ResumeFromBlockOffset(r io.ReaderAt, bo *BlockOffset) (io.ReadCloser, error)
}

// GzipIndexImporter allows GZIP decompressors to resume decompression
// from a specific 32KB window dictionary checkpoint.
type GzipIndexImporter interface {
	ResumeFromGzipIndex(r io.ReaderAt, indexData []byte, targetOffset int64) (reader io.ReadCloser, uncompOffset int64, err error)
}

Once registered via RegisterDecompressor(), TarFS will automatically detect them and use their $O(1)$ fast paths during file reads.

Format Extensions

This library extends the standard TAR format by codifying advanced cross-platform metadata support and random-access indexing into the f4 tar extensions. These extensions provide high-fidelity storage for Windows ACLs, POSIX Xattrs, and $O(1)$ random-access indexes while remaining 100% compliant with standard TAR utilities.

See the technical specification in f4tar.md.

Why "f4"?

The name comes from the f4 file manager, a cross-platform asynchronous clone of Far Manager. This library was built to provide f4 with high-fidelity archive support, ensuring that system-specific metadata like Windows Security Descriptors (ACLs) and Linux Extended Attributes (Xattrs) are preserved seamlessly when moving data across OS boundaries.

License

This project is released under the BSD-3-Clause License. See the LICENSE file for details.

Acknowledgements

Please see CREDITS.md for a detailed list of third-party acknowledgements and inspirations.

Documentation

Index

Constants

View Source
const (
	Store uint16 = 0
	GZIP  uint16 = 1
	BZIP2 uint16 = 2
	XZ    uint16 = 3
	ZSTD  uint16 = 4
)

Compression formats

View Source
const (
	TypeReg           = tar.TypeReg
	TypeRegA          = tar.TypeRegA
	TypeLink          = tar.TypeLink
	TypeSymlink       = tar.TypeSymlink
	TypeChar          = tar.TypeChar
	TypeBlock         = tar.TypeBlock
	TypeDir           = tar.TypeDir
	TypeFifo          = tar.TypeFifo
	TypeCont          = tar.TypeCont
	TypeXHeader       = tar.TypeXHeader
	TypeXGlobalHeader = tar.TypeXGlobalHeader
	TypeGNUSparse     = tar.TypeGNUSparse
	TypeGNULongName   = tar.TypeGNULongName
	TypeGNULongLink   = tar.TypeGNULongLink
	TypeVol           = 'V' // GNUTYPE_VOLHDR (Volume header)
	TypeGNUDumpDir    = 'D' // GNUTYPE_DUMPDIR
	TypeGNUMultiVol   = 'M' // GNUTYPE_MULTIVOL
)
View Source
const (
	FormatUnknown = tar.FormatUnknown
	FormatUSTAR   = tar.FormatUSTAR
	FormatPAX     = tar.FormatPAX
	FormatGNU     = tar.FormatGNU
)
View Source
const MappedStringMark = '\uFFFE'
View Source
const MappedStringMarkStr = "\uFFFE"

Variables

View Source
var (
	ErrHeader          = tar.ErrHeader
	ErrWriteTooLong    = tar.ErrWriteTooLong
	ErrFieldTooLong    = tar.ErrFieldTooLong
	ErrWriteAfterClose = tar.ErrWriteAfterClose
)
View Source
var ErrAlgorithm = errors.New("tar: unsupported compression algorithm")
View Source
var ErrArchiveLocked = errors.New("tar: cannot modify archive, it is locked")

Functions

func AppendTarRecoveryRecord added in v0.1.33

func AppendTarRecoveryRecord(filename string, pct int) error

AppendTarRecoveryRecord генерирует PAR2 для TAR-архива и дописывает его в хвост с F4-футером

func Compress

func Compress(inputFilePath, outputFilePath string) error

Convenience top-level API compatible with targz package

func DetectFormat

func DetectFormat(r io.ReaderAt) (uint16, error)

DetectFormat looks at the magic bytes to determine the compression method.

func Extract

func Extract(inputFilePath, outputFilePath string) error

Convenience top-level API compatible with targz package

func GetStandardIndexPath added in v0.1.10

func GetStandardIndexPath(archivePath string) (string, error)

GetStandardIndexPath attempts to place the SQLite index next to the archive (sidecar). If the directory is read-only, it falls back to the user's cache directory.

func IndexArchive

func IndexArchive(archivePath, indexPath string) error

func LocateShadowStream added in v0.1.32

func LocateShadowStream(ra io.ReaderAt, fileSize int64, method uint16) (int64, int64, error)

LocateShadowStream finds the F4SS Magic Footer and returns the physical offset and size of Stream 2.

func NewReader

func NewReader(r io.Reader) *tar.Reader

func NewWriter

func NewWriter(w io.Writer) *tar.Writer

func RegisterCompressor

func RegisterCompressor(method uint16, comp Compressor)

func RegisterDecompressor

func RegisterDecompressor(method uint16, dcomp Decompressor)

func WriteMagicFooter added in v0.1.35

func WriteMagicFooter(w io.Writer, method uint16, shadowStart, shadowSize int64) error

WriteMagicFooter appends a physical footer at the end of the archive so TarFS can locate the shadow stream in O(1) time without scanning backwards.

Types

type AppendMode

type AppendMode int
const (
	APPEND_MODE_OVERWRITE AppendMode = iota
)

type Archiver

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

func NewArchiver

func NewArchiver(filename string, chroot string, opts ...ArchiverOption) (*Archiver, error)

func (*Archiver) Archive

func (a *Archiver) Archive(ctx context.Context, files map[string]os.FileInfo) error

Archive writes files to the tar sequentially. For TAR, unlike ZIP, we cannot write data streams concurrently to the same file.

func (*Archiver) Close

func (a *Archiver) Close() error

func (*Archiver) SetComment added in v0.1.40

func (a *Archiver) SetComment(comment string)

SetComment sets the global archive comment stored inside the F4SS shadow metadata index.

func (*Archiver) Written added in v0.1.50

func (a *Archiver) Written() (bytes, entries int64)

type ArchiverOption

type ArchiverOption func(*archiverOptions) error

func WithArchiverEmbeddedIndex added in v0.1.28

func WithArchiverEmbeddedIndex(b bool) ArchiverOption

func WithArchiverIndex added in v0.1.8

func WithArchiverIndex(path string) ArchiverOption

func WithArchiverLevel added in v0.1.47

func WithArchiverLevel(level int) ArchiverOption

WithArchiverLevel sets the compression level.

func WithArchiverLock added in v0.1.40

func WithArchiverLock(b bool) ArchiverOption

WithArchiverLock locks the archive to prevent modifications.

func WithArchiverMethod

func WithArchiverMethod(method uint16) ArchiverOption

func WithArchiverPassword added in v0.1.32

func WithArchiverPassword(p string) ArchiverOption

WithArchiverEmbeddedIndex appends the index directly inside the archive (F4 Shadow Stream). WithArchiverPassword enables F4Crypt AES-256-CTR encryption for the archive.

func WithArchiverPathMapping added in v0.1.57

func WithArchiverPathMapping(m map[string]string) ArchiverOption

WithArchiverPathMapping sets the path mapping for logical names in the archive.

func WithArchiverRecovery added in v0.1.34

func WithArchiverRecovery(pct int) ArchiverOption

WithArchiverRecovery устанавливает процент избыточности PAR2 для защиты архива

func WithArchiverSplitSize added in v0.1.37

func WithArchiverSplitSize(size int64) ArchiverOption

WithArchiverSplitSize enables creation of multi-volume archives

func WithArchiverXattrs added in v0.1.13

func WithArchiverXattrs(b bool) ArchiverOption

WithArchiverXattrs enables archiving of extended attributes (xattrs, POSIX ACLs, SELinux).

type BlockOffset added in v0.1.1

type BlockOffset struct {
	BlockOffset int64 // Compressed block offset (bit or byte depending on format)
	DataOffset  int64 // Uncompressed data offset (byte)
}

type BlockOffsetExporter added in v0.1.1

type BlockOffsetExporter interface {
	ExportBlockOffsets() []BlockOffset
}

BlockOffsetExporter exports boundary maps for block-based compression formats (ZSTD, BZIP2).

type BlockOffsetImporter added in v0.1.1

type BlockOffsetImporter interface {
	ResumeFromBlockOffset(r io.ReaderAt, bo *BlockOffset) (io.ReadCloser, error)
}

BlockOffsetImporter resumes decompression from a specific block boundary.

type Compressor

type Compressor func(w io.Writer) (io.WriteCloser, error)

type Decompressor

type Decompressor interface {
	Decompress(r io.Reader) (io.ReadCloser, error)
}

type Extractor

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

func NewExtractor

func NewExtractor(filename, chroot string, opts ...ExtractorOption) (*Extractor, error)

func (*Extractor) Close

func (e *Extractor) Close() error

func (*Extractor) Extract

func (e *Extractor) Extract(ctx context.Context) error

Extract reads TAR sequentially but delegates disk I/O and chmod/chown to a worker pool.

func (*Extractor) Written added in v0.1.51

func (e *Extractor) Written() (bytes, entries int64)

type ExtractorOption

type ExtractorOption func(*extractorOptions) error

func WithExtractorChownErrorHandler

func WithExtractorChownErrorHandler(fn func(name string, err error) error) ExtractorOption

WithExtractorChownErrorHandler allows gracefully ignoring chown errors which frequently happen when extracting archives as an unprivileged user.

func WithExtractorConcurrency

func WithExtractorConcurrency(n int) ExtractorOption

func WithExtractorIncremental added in v0.1.13

func WithExtractorIncremental(b bool) ExtractorOption

WithExtractorIncremental enables processing of GNU Dumpdir headers to remove deleted files during incremental restores.

func WithExtractorKeepBroken added in v0.1.22

func WithExtractorKeepBroken(b bool) ExtractorOption

func WithExtractorKeepNewerFiles added in v0.1.13

func WithExtractorKeepNewerFiles(keep bool) ExtractorOption

WithExtractorKeepNewerFiles prevents overwriting files that are newer on disk (--keep-newer-files)

func WithExtractorKeepOldFiles added in v0.1.13

func WithExtractorKeepOldFiles(keep bool) ExtractorOption

WithExtractorKeepOldFiles prevents overwriting existing files (-k or --keep-old-files)

func WithExtractorMaxFileSize

func WithExtractorMaxFileSize(n int64) ExtractorOption

func WithExtractorMaxRatio

func WithExtractorMaxRatio(n int64) ExtractorOption

func WithExtractorNoTimes added in v0.1.13

func WithExtractorNoTimes(noTimes bool) ExtractorOption

WithExtractorNoTimes prevents restoring original modification times (-m / --touch)

func WithExtractorNumericOwner added in v0.1.13

func WithExtractorNumericOwner(b bool) ExtractorOption

WithExtractorNumericOwner always uses numeric user/group IDs from the archive rather than resolving Uname/Gname (--numeric-owner).

func WithExtractorPassword added in v0.1.32

func WithExtractorPassword(p string) ExtractorOption

WithExtractorSafeWrites extracts files atomically by writing to a temporary file and renaming (--safe-writes). WithExtractorPassword provides the password for decrypting F4Crypt encrypted archives.

func WithExtractorSafeWrites added in v0.1.13

func WithExtractorSafeWrites(b bool) ExtractorOption

func WithExtractorSparse added in v0.1.13

func WithExtractorSparse(b bool) ExtractorOption

WithExtractorSparse enables extracting files as sparse files by seeking over zero-blocks (-S, --sparse).

func WithExtractorStripComponents added in v0.1.13

func WithExtractorStripComponents(count int) ExtractorOption

WithExtractorStripComponents strips the specified number of leading components from file names on extraction (--strip-components)

func WithExtractorTolerant added in v0.1.25

func WithExtractorTolerant(b bool) ExtractorOption

func WithExtractorUnlinkFirst added in v0.1.13

func WithExtractorUnlinkFirst(b bool) ExtractorOption

WithExtractorUnlinkFirst removes existing files prior to extracting over them (-U, --unlink-first).

func WithExtractorXattrs added in v0.1.13

func WithExtractorXattrs(b bool) ExtractorOption

WithExtractorXattrs enables restoration of extended attributes (xattrs, POSIX ACLs, SELinux).

type FSOption added in v0.1.32

type FSOption func(*fsOptions)

func WithFSPassword added in v0.1.32

func WithFSPassword(p string) FSOption

WithFSPassword provides the password for decrypting F4Crypt encrypted archives in TarFS.

type FileNode

type FileNode struct {
	Path           string
	Name           string
	OffsetHeader   int64
	Offset         int64
	Size           int64
	Mode           int64
	ModTime        time.Time
	Type           byte
	LinkName       string
	Uid            int
	Gid            int
	IsTar          bool
	IsSparse       bool
	IsGenerated    bool
	RecursionDepth int
	Xattrs         map[string][]byte
	Acl            []byte
}

type Format

type Format = tar.Format

type GzipIndexExporter added in v0.1.1

type GzipIndexExporter interface {
	ExportGzipIndex() ([]byte, error)
}

GzipIndexExporter exports the complete serialized GZIP index (compatible with zran.c/rapidgzip).

type GzipIndexImporter added in v0.1.1

type GzipIndexImporter interface {
	ResumeFromGzipIndex(r io.ReaderAt, indexData []byte, targetOffset int64) (reader io.ReadCloser, uncompOffset int64, err error)
}

GzipIndexImporter resumes GZIP decompression using the serialized index.

type Header = tar.Header

Drop-in replacements for standard archive/tar types

func FileInfoHeader

func FileInfoHeader(fi os.FileInfo, link string) (*Header, error)

type Index

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

func OpenIndex

func OpenIndex(dsn string) (*Index, error)

func (*Index) Close

func (idx *Index) Close() error

func (*Index) GetClosestBlockOffset added in v0.1.1

func (idx *Index) GetClosestBlockOffset(table string, targetDataOffset int64) (*BlockOffset, error)

func (*Index) GetGzipIndex added in v0.1.1

func (idx *Index) GetGzipIndex() ([]byte, error)

func (*Index) InitMetadata added in v0.1.29

func (idx *Index) InitMetadata() error

func (*Index) Insert

func (idx *Index) Insert(nodes []FileNode) error

func (*Index) InsertBlockOffsets added in v0.1.1

func (idx *Index) InsertBlockOffsets(table string, offsets []BlockOffset) error

func (*Index) List

func (idx *Index) List(p string) ([]FileNode, error)

func (*Index) Lookup

func (idx *Index) Lookup(p string) (*FileNode, error)

func (*Index) RecursiveSize

func (idx *Index) RecursiveSize(p string) (int64, error)

func (*Index) SaveGzipIndex added in v0.1.1

func (idx *Index) SaveGzipIndex(data []byte) error

type MultiVolumeReader added in v0.1.37

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

func OpenMultiVolume added in v0.1.37

func OpenMultiVolume(mainPath string, flag int) (*MultiVolumeReader, int64, error)

func (*MultiVolumeReader) Append added in v0.1.37

func (m *MultiVolumeReader) Append(data []byte) error

func (*MultiVolumeReader) Close added in v0.1.37

func (m *MultiVolumeReader) Close() error

func (*MultiVolumeReader) ReadAt added in v0.1.37

func (m *MultiVolumeReader) ReadAt(p []byte, off int64) (n int, err error)

func (*MultiVolumeReader) WriteAt added in v0.1.37

func (m *MultiVolumeReader) WriteAt(p []byte, off int64) (n int, err error)

type MultiVolumeWriter added in v0.1.37

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

func NewMultiVolumeWriter added in v0.1.37

func NewMultiVolumeWriter(mainPath string, splitSize int64) (*MultiVolumeWriter, error)

func (*MultiVolumeWriter) Close added in v0.1.37

func (m *MultiVolumeWriter) Close() error

func (*MultiVolumeWriter) Name added in v0.1.37

func (m *MultiVolumeWriter) Name() string

func (*MultiVolumeWriter) Sync added in v0.1.37

func (m *MultiVolumeWriter) Sync() error

func (*MultiVolumeWriter) Write added in v0.1.37

func (m *MultiVolumeWriter) Write(p []byte) (n int, err error)

type ReadCloser

type ReadCloser struct {
	*tar.Reader
	// contains filtered or unexported fields
}

func OpenReader

func OpenReader(name string) (*ReadCloser, error)

OpenReader opens a TAR or compressed TAR file (.tar, .tar.gz, .tar.zst, etc.).

func (*ReadCloser) Close

func (rc *ReadCloser) Close() error

func (*ReadCloser) Next added in v0.1.42

func (rc *ReadCloser) Next() (*Header, error)

type Reader

type Reader = tar.Reader

type TarFS

type TarFS struct {
	ArchivePath string
	IndexPath   string
	Index       *Index
	// contains filtered or unexported fields
}

func NewFS

func NewFS(archivePath, indexPath string, opts ...FSOption) (*TarFS, error)

NewFS opens a tar archive as a standard Go fs.FS (File System). This enables integration with http.FileServer, fs.WalkDir, etc. If the SQLite index does not exist, it will be generated automatically.

func (*TarFS) Close

func (t *TarFS) Close() error

func (*TarFS) GetComment added in v0.1.40

func (t *TarFS) GetComment() string

GetComment retrieves the global archive comment stored in the F4SS shadow metadata index.

func (*TarFS) Open

func (t *TarFS) Open(name string) (fs.File, error)

func (*TarFS) RecursiveSize

func (t *TarFS) RecursiveSize(name string) (int64, error)

type Updater

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

func NewUpdater

func NewUpdater(f *os.File, mode AppendMode) (*Updater, error)

NewUpdater opens a .tar or compressed .tar file for appending.

func (*Updater) Append

func (u *Updater) Append(name string, size int64, data []byte) error

Append creates a new file entry in the archive.

func (*Updater) AppendReader added in v0.1.63

func (u *Updater) AppendReader(name string, size int64, r io.Reader) error

AppendReader creates a new file entry in the archive from an io.Reader stream.

func (*Updater) Close

func (u *Updater) Close() error

type WriteCloser

type WriteCloser struct {
	*tar.Writer
	// contains filtered or unexported fields
}

func CreateWriter

func CreateWriter(name string, method uint16, opts ...WriterOption) (*WriteCloser, error)

func (*WriteCloser) Close

func (wc *WriteCloser) Close() error

func (*WriteCloser) Write added in v0.1.8

func (wc *WriteCloser) Write(p []byte) (int, error)

func (*WriteCloser) WriteHeader added in v0.1.8

func (wc *WriteCloser) WriteHeader(hdr *Header) error

type Writer

type Writer = tar.Writer

type WriterOption added in v0.1.8

type WriterOption func(*writerOptions)

func WithWriterIndex added in v0.1.8

func WithWriterIndex(indexPath string) WriterOption

WithWriterIndex enables on-the-fly indexing during archive creation.

func WithWriterLevel added in v0.1.47

func WithWriterLevel(level int) WriterOption

func WithWriterSplitSize added in v0.1.37

func WithWriterSplitSize(size int64) WriterOption

type XCryptHeader added in v0.1.49

type XCryptHeader struct {
	Version    uint8
	KdfAlgo    uint8
	Cipher     uint8
	Iterations uint32
	Salt       []byte
	IV         []byte
	MAC        []byte
}

XCryptHeader represents the 93-byte binary header for encrypted streams

func (*XCryptHeader) DeriveKey added in v0.1.49

func (h *XCryptHeader) DeriveKey(password string) []byte

func (*XCryptHeader) Encode added in v0.1.49

func (h *XCryptHeader) Encode() []byte

Jump to

Keyboard shortcuts

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