MCPcopy
hub / github.com/wagoodman/dive / AddChild

Method AddChild

dive/filetree/file_node.go:90–106  ·  view source on GitHub ↗

AddChild creates a new node relative to the current FileNode.

(name string, data FileInfo)

Source from the content-addressed store, hash-verified

88
89// AddChild creates a new node relative to the current FileNode.
90func (node *FileNode) AddChild(name string, data FileInfo) (child *FileNode) {
91 // never allow processing of purely whiteout flag files (for now)
92 if strings.HasPrefix(name, doubleWhiteoutPrefix) {
93 return nil
94 }
95
96 child = NewNode(node, name, data)
97 if node.Children[name] != nil {
98 // tree node already exists, replace the payload, keep the children
99 node.Children[name].Data.FileInfo = *data.Copy()
100 } else {
101 node.Children[name] = child
102 node.Tree.Size++
103 }
104
105 return child
106}
107
108// Remove deletes the current FileNode from it's parent FileNode's relations.
109func (node *FileNode) Remove() error {

Callers 5

TestStringCollapsedFunction · 0.80
TestStringFunction · 0.80
TestAddChildFunction · 0.80
TestRemoveChildFunction · 0.80
AddPathMethod · 0.80

Calls 2

NewNodeFunction · 0.85
CopyMethod · 0.45

Tested by 4

TestStringCollapsedFunction · 0.64
TestStringFunction · 0.64
TestAddChildFunction · 0.64
TestRemoveChildFunction · 0.64