codec

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2014 License: LGPL-3.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const (
	GobName      = "gob"
	GobExtension = "gobz"
	Version      = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	// Write the given FileInfo structure to the given writer.
	// The codec must protect the written data against modification, usually by hashing the contained information
	Serialize(paths map[string]*godi.FileInfo, writer io.Writer) (err error)

	// Read a FileInfo slice from the given reader. The fileinfo Paths must be relative to the index file
	// An error must be returned if the data read could not be verified.
	Deserialize(reader io.Reader) ([]SerializedFileInfo, error)

	// Extension returns the file extension of the codec, without the '.' prefix
	Extension() string
}

Represents a codec's standard capabilities. A codec is a specialized implementation able to read and write indices of file hash information NOTE: Even though it would be more idiomatic to have two interfaces for read and write respectively, we just don't need it here

func NewByPath

func NewByPath(path string) Codec

Finds a codec which can decode the file at the given path. We work strictly by name.

type Gob

type Gob struct {
}

Reads and writes a file structured like so - version - numEntries - gobValue... - sha1 (hash of all hashes in prior map)

func (*Gob) Deserialize

func (g *Gob) Deserialize(reader io.Reader) ([]SerializedFileInfo, error)

func (*Gob) Extension

func (g *Gob) Extension() string

func (*Gob) Serialize

func (g *Gob) Serialize(paths map[string]*godi.FileInfo, writer io.Writer) (err error)

type SerializedFileInfo

type SerializedFileInfo struct {
	FileInfo godi.FileInfo
	RelaPath string
}

Used as structure when deserializing information It contains both absolute and relative paths to allow dealing with relocated trees, or relocated seal files

Jump to

Keyboard shortcuts

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