Documentation
¶
Overview ¶
Package linkpath resolves symlink chains physically so containment checks can see where a link really points, including links whose final components do not exist yet.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Escapes ¶
Escapes reports whether the symlink at from leaves the tree that links describes. The tree is recorded, not read from disk: links maps the slash-separated path of every symlink, relative to the tree root, to its target. Resolution follows the recorded links exactly like Resolve follows physical ones (a dangling tail is resolved lexically), so the answer cannot change when the files the links were read from change afterwards. A link chain that loops does not escape.
func Resolve ¶
Resolve returns the physical absolute path that target refers to. It follows every symlink it meets, like filepath.EvalSymlinks. Unlike EvalSymlinks, it also resolves a path whose tail does not exist: the longest existing prefix is resolved physically, and the missing remainder is joined lexically. A dangling link therefore still reports where it would land once the missing path is created. Parent components are applied only after the symlinks before them are resolved, so "link/../x" is not collapsed to a sibling of "link".
Resolve fails with errUtils.ErrSymlinkLoop when the links form a loop, with errUtils.ErrPathThroughNonDirectory when the path passes through a non-directory, and with another error when it cannot be inspected. Callers decide separately what each failure means.
func ResolveRecorded ¶
ResolveRecorded returns the slash-separated path, relative to the tree root, that from refers to once every recorded link on the way is followed. Like Escapes it reads only links, never the disk, so a caller can test where a captured link lands without looking at the source again. The root itself resolves to the empty path. ResolveRecorded reports false when the chain leaves the tree or loops, because neither names a path inside the tree.
func TraversedRecorded ¶
TraversedRecorded returns, in the order the filesystem looks them up, the slash-separated path of every entry that resolving from through the recorded links passes through, relative to the tree root. A parent component is applied only after the directory before it was looked up, so "cache/p/../x" traverses "cache" and "cache/p" even though it reduces to "x". Paths reached through a recorded link are reported by the physical location they resolve to. It reports false when the chain leaves the tree or loops.
Types ¶
This section is empty.