path

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package path implements utilities for resolving paths within ipfs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitAbsPath

func SplitAbsPath(fpath Path) (mh.Multihash, []string, error)

SplitAbsPath clean up and split fpath. It extracts the first component (which must be a Multihash) and return it separately.

Types

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

ErrNoLink is returned when a link is not found in a path

func (ErrNoLink) Error

func (e ErrNoLink) Error() string

type Path

type Path string

TODO: debate making this a private struct wrapped in a public interface would allow us to control creation, and cache segments.

func FromKey

func FromKey(k u.Key) Path

FromKey safely converts a Key type to a Path type

func FromString

func FromString(s string) Path

FromString safely converts a string type to a Path type

func (Path) Segments

func (p Path) Segments() []string

func (Path) String

func (p Path) String() string

type Resolver

type Resolver struct {
	DAG merkledag.DAGService
}

Resolver provides path resolution to IPFS It has a pointer to a DAGService, which is uses to resolve nodes.

func (s *Resolver) ResolveLinks(ndd *merkledag.Node, names []string) (
	result []*merkledag.Node, err error)

ResolveLinks iteratively resolves names by walking the link hierarchy. Every node is fetched from the DAGService, resolving the next name. Returns the list of nodes forming the path, starting with ndd. This list is guaranteed never to be empty.

ResolveLinks(nd, []string{"foo", "bar", "baz"}) would retrieve "baz" in ("bar" in ("foo" in nd.Links).Links).Links

func (*Resolver) ResolvePath

func (s *Resolver) ResolvePath(fpath Path) (*merkledag.Node, error)

ResolvePath fetches the node for given path. It returns the last item returned by ResolvePathComponents.

func (*Resolver) ResolvePathComponents

func (s *Resolver) ResolvePathComponents(fpath Path) ([]*merkledag.Node, error)

ResolvePathComponents fetches the nodes for each segment of the given path. It uses the first path component as a hash (key) of the first node, then resolves all other components walking the links, with ResolveLinks.

Jump to

Keyboard shortcuts

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