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

Method AddExternalFile

filetree/tree.go:289–303  ·  view source on GitHub ↗

AddExternalFile adds an external file outside of root of file tree and triggers an update, returning the Node for it, or error if [filepath.Abs] fails.

(fpath string)

Source from the content-addressed store, hash-verified

287// and triggers an update, returning the Node for it, or
288// error if [filepath.Abs] fails.
289func (ft *Tree) AddExternalFile(fpath string) (*Node, error) {
290 pth, err := filepath.Abs(fpath)
291 if err != nil {
292 return nil, err
293 }
294 if _, err := os.Stat(pth); err != nil {
295 return nil, err
296 }
297 if has, _ := ft.hasExternalFile(pth); has {
298 return ft.externalNodeByPath(pth)
299 }
300 ft.externalFiles = append(ft.externalFiles, pth)
301 ft.Child(0).(Filer).AsFileNode().Update()
302 return ft.externalNodeByPath(pth)
303}
304
305// removeExternalFile removes external file from maintained list; returns true if removed.
306func (ft *Tree) removeExternalFile(fpath string) bool {

Callers

nothing calls this directly

Calls 7

hasExternalFileMethod · 0.95
externalNodeByPathMethod · 0.95
ChildMethod · 0.80
UpdateMethod · 0.65
AsFileNodeMethod · 0.65
AbsMethod · 0.45
StatMethod · 0.45

Tested by

no test coverage detected