MCPcopy Create free account
hub / github.com/cogentcore/core / externalNodeByPath

Method externalNodeByPath

filetree/tree.go:329–342  ·  view source on GitHub ↗

externalNodeByPath returns Node for given file path, and true, if it exists in the external files list. Otherwise returns nil, false.

(fpath string)

Source from the content-addressed store, hash-verified

327// externalNodeByPath returns Node for given file path, and true, if it
328// exists in the external files list. Otherwise returns nil, false.
329func (ft *Tree) externalNodeByPath(fpath string) (*Node, error) {
330 ehas, i := ft.hasExternalFile(fpath)
331 if !ehas {
332 return nil, fmt.Errorf("ExtFile not found on list: %v", fpath)
333 }
334 ekid := ft.ChildByName(externalFilesName, 0)
335 if ekid == nil {
336 return nil, fmt.Errorf("ExtFile not updated -- no ExtFiles node")
337 }
338 if n := ekid.AsTree().Child(i); n != nil {
339 return AsNode(n), nil
340 }
341 return nil, fmt.Errorf("ExtFile not updated; index invalid")
342}

Callers 2

AddExternalFileMethod · 0.95
FindFileMethod · 0.80

Calls 6

hasExternalFileMethod · 0.95
ChildByNameMethod · 0.80
ChildMethod · 0.80
AsNodeFunction · 0.70
ErrorfMethod · 0.65
AsTreeMethod · 0.65

Tested by

no test coverage detected