Documentation ¶
Overview ¶
Package path implements utilities for resolving paths within ipfs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadPath = errors.New("invalid 'ipfs ref' path")
ErrBadPath is returned when a given path is incorrectly formatted
var ErrNoComponents = errors.New(
"path must contain at least one component")
Paths after a protocol must contain at least one component
Functions ¶
func ResolveSingle ¶ added in v0.4.5
func SplitAbsPath ¶
SplitAbsPath clean up and split fpath. It extracts the first component (which must be a Multihash) and return it separately.
Types ¶
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 FromString ¶
FromString safely converts a string type to a Path type
func ParseCidToPath ¶ added in v0.4.5
func (Path) IsJustAKey ¶ added in v0.4.0
IsJustAKey returns true if the path is of the form <key> or /ipfs/<key>.
func (Path) PopLastSegment ¶ added in v0.4.0
PopLastSegment returns a new Path without its final segment, and the final segment, separately. If there is no more to pop (the path is just a key), the original path is returned.
type Resolver ¶
type Resolver struct { DAG dag.DAGService ResolveOnce func(ctx context.Context, ds dag.DAGService, nd node.Node, name string) (*node.Link, error) }
Resolver provides path resolution to IPFS It has a pointer to a DAGService, which is uses to resolve nodes. TODO: now that this is more modular, try to unify this code with the
the resolvers in namesys
func NewBasicResolver ¶ added in v0.4.5
func NewBasicResolver(ds dag.DAGService) *Resolver
func (*Resolver) ResolveLinks ¶
func (s *Resolver) ResolveLinks(ctx context.Context, ndd node.Node, names []string) ([]node.Node, 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 ¶
ResolvePath fetches the node for given path. It returns the last item returned by ResolvePathComponents.
func (*Resolver) ResolvePathComponents ¶
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.