cat.go 563 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
package core_io

// TODO rename package to something that doesn't conflict with io/ioutil.
// Pretty names are hard to find.
//
// Candidates:
//
// go-ipfs/core/unix
// go-ipfs/core/io
// go-ipfs/core/ioutil
// go-ipfs/core/coreio
// go-ipfs/core/coreunix

import (
	"io"

	core "github.com/jbenet/go-ipfs/core"
	uio "github.com/jbenet/go-ipfs/unixfs/io"
	u "github.com/jbenet/go-ipfs/util"
)

func Cat(n *core.IpfsNode, k u.Key) (io.Reader, error) {
23
	dagNode, err := n.Resolve(k)
24 25 26
	if err != nil {
		return nil, err
	}
27
	return uio.NewDagReader(dagNode, n.DAG)
28
}