Path returns a slash-delimited string from the root of the greater tree to the current node (e.g. /a/path/to/here)
()
| 273 | |
| 274 | // Path returns a slash-delimited string from the root of the greater tree to the current node (e.g. /a/path/to/here) |
| 275 | func (node *FileNode) Path() string { |
| 276 | if node.path == "" { |
| 277 | var path []string |
| 278 | curNode := node |
| 279 | for { |
| 280 | if curNode.Parent == nil { |
| 281 | break |
| 282 | } |
| 283 | |
| 284 | name := curNode.Name |
| 285 | if curNode == node { |
| 286 | // white out prefixes are fictitious on leaf nodes |
| 287 | name = strings.TrimPrefix(name, whiteoutPrefix) |
| 288 | } |
| 289 | |
| 290 | path = append([]string{name}, path...) |
| 291 | curNode = curNode.Parent |
| 292 | } |
| 293 | node.path = "/" + strings.Join(path, "/") |
| 294 | } |
| 295 | return strings.Replace(node.path, "//", "/", -1) |
| 296 | } |
| 297 | |
| 298 | // deriveDiffType determines a DiffType to the current FileNode. Note: the DiffType of a node is always the DiffType of |
| 299 | // its attributes and its contents. The contents are the bytes of the file of the children of a directory. |
no outgoing calls