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)
| 287 | // and triggers an update, returning the Node for it, or |
| 288 | // error if [filepath.Abs] fails. |
| 289 | func (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. |
| 306 | func (ft *Tree) removeExternalFile(fpath string) bool { |
nothing calls this directly
no test coverage detected