mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-15 07:58:15 +08:00

Currently the "path" module does two very different things: * Defines how ipfs paths look like and provides tools to parse/split etc. * Provides a resolver to resolve paths. This moves the resolver stuff to `path/resolver` and leaves the path utilities in `path`. The result is that now the IPFS `path` package just defines what a path looks like and becomes a module that can be exported/re-used without problems. Currently there are circular dependency cycles (resolve_test -> merkledag/utils, merkledag->path), which the prevent the export of merkledag itself. License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
25 lines
536 B
Go
25 lines
536 B
Go
package coreunix
|
|
|
|
import (
|
|
"context"
|
|
|
|
core "github.com/ipfs/go-ipfs/core"
|
|
path "github.com/ipfs/go-ipfs/path"
|
|
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
|
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
|
)
|
|
|
|
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (uio.DagReader, error) {
|
|
r := &resolver.Resolver{
|
|
DAG: n.DAG,
|
|
ResolveOnce: uio.ResolveUnixfsOnce,
|
|
}
|
|
|
|
dagNode, err := core.Resolve(ctx, n.Namesys, r, path.Path(pstr))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return uio.NewDagReader(ctx, dagNode, n.DAG)
|
|
}
|