Remove deletes the current FileNode from it's parent FileNode's relations.
()
| 107 | |
| 108 | // Remove deletes the current FileNode from it's parent FileNode's relations. |
| 109 | func (node *FileNode) Remove() error { |
| 110 | if node == node.Tree.Root { |
| 111 | return fmt.Errorf("cannot remove the tree root") |
| 112 | } |
| 113 | for _, child := range node.Children { |
| 114 | err := child.Remove() |
| 115 | if err != nil { |
| 116 | return err |
| 117 | } |
| 118 | } |
| 119 | delete(node.Parent.Children, node.Name) |
| 120 | node.Tree.Size-- |
| 121 | return nil |
| 122 | } |
| 123 | |
| 124 | // String shows the filename formatted into the proper color (by DiffType), additionally indicating if it is a symlink. |
| 125 | func (node *FileNode) String() string { |
no outgoing calls