@@ -16,39 +16,6 @@ import (
1616 cid "gx/ipfs/QmapdYm1b22Frv3k17fqrBYTFRxwiaVJkB299Mfn33edeB/go-cid"
1717)
1818
19- // path implements coreiface.Path
20- type path struct {
21- path ipfspath.Path
22- }
23-
24- // resolvedPath implements coreiface.resolvedPath
25- type resolvedPath struct {
26- path
27- cid * cid.Cid
28- root * cid.Cid
29- remainder string
30- }
31-
32- // IpfsPath parses the path from `c`, reruns the parsed path.
33- func (api * CoreAPI ) IpfsPath (c * cid.Cid ) coreiface.ResolvedPath {
34- return & resolvedPath {
35- path : path {ipfspath .Path ("/ipfs/" + c .String ())},
36- cid : c ,
37- root : c ,
38- remainder : "" ,
39- }
40- }
41-
42- // IpldPath parses the path from `c`, reruns the parsed path.
43- func (api * CoreAPI ) IpldPath (c * cid.Cid ) coreiface.ResolvedPath {
44- return & resolvedPath {
45- path : path {ipfspath .Path ("/ipld/" + c .String ())},
46- cid : c ,
47- root : c ,
48- remainder : "" ,
49- }
50- }
51-
5219// ResolveNode resolves the path `p` using Unixfs resolver, gets and returns the
5320// resolved Node.
5421func (api * CoreAPI ) ResolveNode (ctx context.Context , p coreiface.Path ) (ipld.Node , error ) {
@@ -79,7 +46,7 @@ func resolvePath(ctx context.Context, ng ipld.NodeGetter, nsys namesys.NameSyste
7946 return p .(coreiface.ResolvedPath ), nil
8047 }
8148
82- ipath := p .( * path ). path
49+ ipath := ipfspath . Path ( p . String ())
8350 ipath , err := core .ResolveIPNS (ctx , nsys , ipath )
8451 if err == core .ErrNoNamesys {
8552 return nil , coreiface .ErrOffline
@@ -113,48 +80,5 @@ func resolvePath(ctx context.Context, ng ipld.NodeGetter, nsys namesys.NameSyste
11380 return nil , err
11481 }
11582
116- return & resolvedPath {
117- path : path {ipath },
118- cid : node .Cid (),
119- root : root ,
120- remainder : gopath .Join (rest ... ),
121- }, nil
122- }
123-
124- // ParsePath parses path `p` using ipfspath parser, returns the parsed path.
125- func (api * CoreAPI ) ParsePath (p string ) (coreiface.Path , error ) {
126- pp , err := ipfspath .ParsePath (p )
127- if err != nil {
128- return nil , err
129- }
130-
131- return & path {path : pp }, nil
132- }
133-
134- func (p * path ) String () string {
135- return p .path .String ()
136- }
137-
138- func (p * path ) Namespace () string {
139- if len (p .path .Segments ()) < 1 {
140- panic ("path without namespace" ) //this shouldn't happen under any scenario
141- }
142- return p .path .Segments ()[0 ]
143- }
144-
145- func (p * path ) Mutable () bool {
146- //TODO: MFS: check for /local
147- return p .Namespace () == "ipns"
148- }
149-
150- func (p * resolvedPath ) Cid () * cid.Cid {
151- return p .cid
152- }
153-
154- func (p * resolvedPath ) Root () * cid.Cid {
155- return p .root
156- }
157-
158- func (p * resolvedPath ) Remainder () string {
159- return p .remainder
83+ return coreiface .NewResolvedPath (ipath , node .Cid (), root , gopath .Join (rest ... )), nil
16084}
0 commit comments