manifest

package
v0.0.0-...-288f078 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidToken = errors.New("Invalid token")

Functions

func EscapeName

func EscapeName(s string) string

func UnescapeName

func UnescapeName(s string) string

Types

type BlockLocator

type BlockLocator struct {
	Digest blockdigest.BlockDigest
	Size   int
	Hints  []string
}

func ParseBlockLocator

func ParseBlockLocator(s string) (b BlockLocator, err error)

type FileSegment

type FileSegment struct {
	Locator string
	// Offset (within this block) of this data segment
	Offset int
	Len    int
}

FileSegment is a portion of a file that is contained within a single block.

type FileStreamSegment

type FileStreamSegment struct {
	SegPos uint64
	SegLen uint64
	Name   string
}

FileStreamSegment is a portion of a file described as a segment of a stream.

type Manifest

type Manifest struct {
	Text string
	Err  error
}

func (*Manifest) BlockIterWithDuplicates

func (m *Manifest) BlockIterWithDuplicates() <-chan blockdigest.BlockLocator

BlockIterWithDuplicates iterates over the block locators of a manifest.

Blocks may appear multiple times within the same manifest if they are used by multiple files. In that case this Iterator will output the same block multiple times.

In order to detect parse errors, caller must check m.Err after the returned channel closes.

func (Manifest) Extract

func (m Manifest) Extract(srcpath, relocate string) (ret Manifest)

Extract extracts some or all of the manifest and returns the extracted portion as a normalized manifest. This is a swiss army knife function that can be several ways:

If 'srcpath' and 'relocate' are '.' it simply returns an equivalent manifest in normalized form.

Extract(".", ".")  // return entire normalized manfest text

If 'srcpath' points to a single file, it will return manifest text for just that file. The value of "relocate" is can be used to rename the file or set the file stream.

Extract("./foo", ".")          // extract file "foo" and put it in stream "."
Extract("./foo", "./bar")      // extract file "foo", rename it to "bar" in stream "."
Extract("./foo", "./bar/")     // extract file "foo", rename it to "./bar/foo"
Extract("./foo", "./bar/baz")  // extract file "foo", rename it to "./bar/baz")

Otherwise it will return the manifest text for all streams with the prefix in "srcpath" and place them under the path in "relocate".

Extract("./stream", ".")      // extract "./stream" to "." and "./stream/subdir" to "./subdir")
Extract("./stream", "./bar")  // extract "./stream" to "./bar" and "./stream/subdir" to "./bar/subdir")

func (*Manifest) FileSegmentIterByName

func (m *Manifest) FileSegmentIterByName(filepath string) <-chan *FileSegment

func (*Manifest) StreamIter

func (m *Manifest) StreamIter() <-chan ManifestStream

type ManifestStream

type ManifestStream struct {
	StreamName string
	Blocks     []string

	FileStreamSegments []FileStreamSegment
	Err                error
	// contains filtered or unexported fields
}

ManifestStream represents a single line from a manifest.

func (*ManifestStream) FileSegmentIterByName

func (s *ManifestStream) FileSegmentIterByName(filepath string) <-chan *FileSegment

Jump to

Keyboard shortcuts

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