Documentation ¶
Overview ¶
Package fspath provides efficient tools for working with file paths in Linux-compatible filesystem implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is similar to strings.Builder, but is used to produce pathnames given path components in reverse order (from leaf to root). This is useful in the common case where a filesystem is represented by a tree of named nodes, and the path to a given node must be produced by walking upward from that node to a given root.
func (*Builder) AppendString ¶
AppendString appends the given string to b's buffer.
func (*Builder) PrependByte ¶
PrependByte prepends the given byte to b's buffer.
func (*Builder) PrependComponent ¶
PrependComponent prepends the given path component to b's buffer. A path separator is automatically inserted if appropriate.
func (*Builder) PrependString ¶
PrependString prepends the given string to b's buffer.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
An Iterator represents either a path component in a Path or a terminal iterator indicating that the end of the path has been reached.
Iterator is immutable and copyable by value. The zero value of Iterator is valid, and represents a terminal iterator.
func (Iterator) Next ¶
Next returns an iterator to the path component after it. If it is the last component in the path, Next returns a terminal iterator.
Preconditions: it.Ok().
type Path ¶
type Path struct { // Begin is an iterator to the first path component in the relative part of // the path. // // Path doesn't store information about path components after the first // since this would require allocation. Begin Iterator // If true, the path is absolute, such that lookup should begin at the // filesystem root. If false, the path is relative, such that where lookup // begins is unspecified. Absolute bool // If true, the pathname contains trailing path separators, so the last // path component must exist and resolve to a directory. Dir bool }
Path contains the information contained in a pathname string.
Path is copyable by value. The zero value for Path is equivalent to fspath.Parse(""), i.e. the empty path.
func Parse ¶
Parse parses a pathname as described by path_resolution(7), except that empty pathnames will be parsed successfully to a Path for which Path.Absolute == Path.Dir == Path.HasComponents() == false. (This is necessary to support AT_EMPTY_PATH.)
func (Path) HasComponents ¶
HasComponents returns true if p contains a non-zero number of path components.