mndx

package
v0.0.0-...-95cd7cf Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDirFileNameClash = errors.New(`mndx: file and directory have clashing names`)
	ErrExists           = errors.New(`mndx: file has clashing name`)
	ErrNotExists        = errors.New(`mndx: no such file or directory`)
	ErrNotADirectory    = errors.New(`mndx: not a directory`)
)

Error constants

Functions

func Decorate

func Decorate(ctx context.Context, c *client.Client) error

Decorate adds a FilenameMapper to the provided client.

It will automatically download and parse the root file.

Types

type File

type File struct {
	Name string
	Size uint32

	LocaleFlags uint32
	FileDataID  uint32

	EncodingKey ngdp.ContentHash
}

A File contains file metadata, including its content hash.

type FilenameMap

type FilenameMap map[string]*File

A FilenameMap maps file paths to their corresponding File.

func Parse

func Parse(r io.Reader) (FilenameMap, error)

Parse parses the provided MNDX file and returns a FilenameMap.

The MNDX file should not be BLTE-encoded.

func (FilenameMap) ToContentHash

func (m FilenameMap) ToContentHash(fn string) (h ngdp.ContentHash, ok bool)

ToContentHash returns the content hash for a given file path.

type TreeDents

type TreeDents []*TreeDirectoryEntry

A TreeDents is a sort.Interface of TreeDirectoryEntry structs.

func (TreeDents) Len

func (td TreeDents) Len() int

func (TreeDents) Less

func (td TreeDents) Less(i, j int) bool

func (TreeDents) Swap

func (td TreeDents) Swap(i, j int)

type TreeDirectory

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

A TreeDirectory is a container for TreeDirectory or TreeFile structs, which can be addressed by their name.

func ToTree

func ToTree(fileMap FilenameMap) (*TreeDirectory, error)

ToTree takes a FilenameMap and converts it into a tree structure.

func (*TreeDirectory) Get

func (td *TreeDirectory) Get(filePath string) (TreeDirectoryEntry, error)

Get returns a TreeDirectoryEntry for a given /-separated path.

func (*TreeDirectory) List

func (td *TreeDirectory) List() []TreeDirectoryEntry

List returns everything contained within this directory.

func (*TreeDirectory) ToContentHash

func (d *TreeDirectory) ToContentHash(fn string) (h ngdp.ContentHash, ok bool)

ToContentHash returns the content hash for a given file path.

type TreeDirectoryEntry

type TreeDirectoryEntry struct {
	Name string

	Directory *TreeDirectory
	File      *TreeFile
}

A TreeDirectoryEntry is a directory entry, either a nested directory or a file.

type TreeFile

type TreeFile struct {
	Size uint32

	LocaleFlags uint32
	FileDataID  uint32

	EncodingKey [md5.Size]byte
}

A TreeFile contains the metadata for a file, including its CDN hash.

Jump to

Keyboard shortcuts

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