pack

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package pack provides functions for combining and parsing pack files.

Index

Constants

View Source
const (

	// HeaderSize is the header's constant overhead (independent of #entries)
	HeaderSize = headerLengthSize + crypto.Extension
)

Variables

View Source
var EntrySize = uint(binary.Size(restic.BlobType(0)) + headerLengthSize + len(restic.ID{}))

Functions

func List

func List(k *crypto.Key, rd io.ReaderAt, size int64) (entries []restic.Blob, hdrSize uint32, err error)

List returns the list of entries found in a pack file and the length of the header (including header size and crypto overhead)

func PackedSizeOfBlob added in v0.12.0

func PackedSizeOfBlob(blobLength uint) uint

PackedSizeOfBlob returns the size a blob actually uses when saved in a pack

Types

type InvalidFileError

type InvalidFileError struct {
	Message string
}

InvalidFileError is return when a file is found that is not a pack file.

func (InvalidFileError) Error

func (e InvalidFileError) Error() string

type Packer

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

Packer is used to create a new Pack.

func NewPacker

func NewPacker(k *crypto.Key, wr io.Writer) *Packer

NewPacker returns a new Packer that can be used to pack blobs together.

func (*Packer) Add

func (p *Packer) Add(t restic.BlobType, id restic.ID, data []byte) (int, error)

Add saves the data read from rd as a new blob to the packer. Returned is the number of bytes written to the pack.

func (*Packer) Blobs

func (p *Packer) Blobs() []restic.Blob

Blobs returns the slice of blobs that have been written.

func (*Packer) Count

func (p *Packer) Count() int

Count returns the number of blobs in this packer.

func (*Packer) Finalize

func (p *Packer) Finalize() (uint, error)

Finalize writes the header for all added blobs and finalizes the pack. Returned are the number of bytes written, including the header.

func (*Packer) Size

func (p *Packer) Size() uint

Size returns the number of bytes written so far.

func (*Packer) String

func (p *Packer) String() string

Jump to

Keyboard shortcuts

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