sar

package
v0.0.0-...-1b96e9a Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package sar implements a high level interface to manipulate SARchive files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFromPath

func CreateFromPath(out io.Writer, path string, options ...CreateOption) error

func GenerateTreeFromPath

func GenerateTreeFromPath(path string) (*toc.TOC, bool, error)

Types

type CreateOption

type CreateOption func(*createOptionData)

func WithChecksum

func WithChecksum(kind sardata.ChecksumScheme) CreateOption

func WithCompression

func WithCompression(kind sardata.CompressionScheme, level int) CreateOption

type OpenOption

type OpenOption func(*openOptionData)

OpenOption functions can be supplied to the Open function

func WithRawTOC

func WithRawTOC(val bool) OpenOption

WithRawTOC is an OpenOption which instructs Open to duplicate the raw manifest block. This can be useful for storing the manifest on disk next to the unpacked Archive, for example.

func WithUnpackBufferSize

func WithUnpackBufferSize(factor int) OpenOption

WithUnpackBufferSize is an OpenOption factory which indicates the number of bytes that UnpackTo will attempt to decompress ahead of time. Default if unspecified is 16MB.

func WithVerification

func WithVerification(val VerifyStateEnum) OpenOption

WithVerification allows you to dictate how the checksum in the archive is verified.

type OpenedArchive

type OpenedArchive struct {
	TOC *toc.TOC
	// contains filtered or unexported fields
}

OpenedArchive represends an Open'd sar file.

func Open

func Open(r readSeekCloser, options ...OpenOption) (ret *OpenedArchive, err error)

Open opens a SARchive from the given reader.

It will read and validate the table of contents, and open the archive data block but not read any of the data.

To get a positive confirmation for the integrity of the archive, you must call Close() and observe the error (or you can use EarlyVerify to get a preemptive integrity check).

func (*OpenedArchive) Close

func (a *OpenedArchive) Close() error

Close closes the archive and the underlying reader. If UnpackTo hasn't been called, then this will also verify the checksum.

func (*OpenedArchive) RawTOC

func (a *OpenedArchive) RawTOC() ([]byte, error)

RawTOC returns the raw bytes for the compressed TOC block if WithRawTOC was provided.

func (*OpenedArchive) UnpackTo

func (a *OpenedArchive) UnpackTo(ctx context.Context, root string) error

UnpackTo does a streaming unpack of the entire Archive to the provided location.

root must be either a non-existant path, or a path to an empty directory.

It is invalid to call UnpackTo twice, or to call it on a Close()'d Archive.

type VerifyStateEnum

type VerifyStateEnum int

VerifyStateEnum allows you to control how Open will verify the package integrity. It defaults to VerifyLate.

const (
	// Checksum verification will occur when calling OpenedArchive.Close()
	VerifyLate VerifyStateEnum = iota

	// Checksum verification will occur when calling Open()
	VerifyEarly

	// Checksum verification will be skipped.
	VerifyNever
)

Valid values of VerifyStateEnum

Directories

Path Synopsis
Package sardata implements IO routines for reading and writing various chunks of the SARchive format, including checksums, blocks (table of contents and archive data), and the 'magic' bytes.
Package sardata implements IO routines for reading and writing various chunks of the SARchive format, including checksums, blocks (table of contents and archive data), and the 'magic' bytes.
toc
Package toc defines the Table of Contents format for SARchives (as proto).
Package toc defines the Table of Contents format for SARchives (as proto).

Jump to

Keyboard shortcuts

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