// NewDirectoryFromNode loads a unixfs directory from the given IPLD node and
// DAGService.
NewDirectoryFromNode loads a unixfs directory from the given IPLD node and
DAGService.
// NewDirectoryFromNode loads a unixfs directory from the given IPLD node and // DAGService .
func NewDirectoryFromNode(dserv ipld.DAGService, node ipld.Node) (Directory, error) {
	protoBufNode, ok := node.(*mdag.ProtoNode)
	if !ok {
		return nil, ErrNotADir
	}
	fsNode, err := format.FSNodeFromBytes(protoBufNode.Data())
	if err != nil {
		return nil, err
	}
	switch fsNode.Type() {
	case format.TDirectory:
		return &DynamicDirectory{newBasicDirectoryFromNode(dserv, protoBufNode.Copy().(*mdag.ProtoNode))}, nil
	case format.THAMTShard:
		shard, err := hamt.NewHamtFromDag(dserv, node)
		if err != nil {
			return nil, err
		}
		return &DynamicDirectory{&HAMTDirectory{shard, dserv, 0}}, nil
	}
	return nil, ErrNotADir
}
func NewDirectoryFromNode ( dserv ipld . DAGService , node ipld . Node ) ( Directory , error ) { protoBufNode , ok := node . ( * mdag . ProtoNode ) if ! ok { return nil , ErrNotADir } fsNode , err := format . FSNodeFromBytes ( protoBufNode . Data ( ) ) if err != nil { return nil , err } switch fsNode . Type ( ) { case format . TDirectory : return & DynamicDirectory { newBasicDirectoryFromNode ( dserv , protoBufNode . Copy ( ) . ( * mdag . ProtoNode ) ) } , nil case format . THAMTShard : shard , err := hamt . NewHamtFromDag ( dserv , node ) if err != nil { return nil , err } return & DynamicDirectory { & HAMTDirectory { shard , dserv , 0 } } , nil } return nil , ErrNotADir }
NewDirectoryFromNode loads a unixfs directory from the given IPLD node and
DAGService.
NewDirectoryFromNode loads a unixfs directory from the given IPLD node and DAGService .