path

package
v0.0.0-...-cbd58c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package path implements path manipulation routines used by cmaketobzl.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitCommonRoot

func SplitCommonRoot(paths []Path) (Path, []Path)

SplitCommonRoot finds the longest command whole-segment prefix of the provided path and returns that along with each path stripped of that prefix.

func SplitCommonRootString

func SplitCommonRootString(paths []string) (string, []string)

SplitCommonRootString finds the longest command whole-segment prefix of the provided path and returns that along with each path stripped of that prefix as /-delimited strings.

func Walk

func Walk(root Path, visit Visitor) error

Walk traverses the directory at root in depth-first order, calling visit on selected subdirectories, begining at root.

Types

type Path

type Path []string

Path is a slice of string segments, representing a filesystem path.

func Append

func Append(p Path, ps ...Path) Path

Append appends additional elements to the end of path, disregarding the leading '/' on appended elements.

func AppendString

func AppendString(p Path, elem ...string) Path

AppendString appends additional string elements to the end of path.

func Join

func Join(p Path, ps ...Path) Path

Join joins any number of paths and returns the result.

func JoinString

func JoinString(p Path, elem ...string) Path

JoinString joins path and any number of additional string elements, returning the result.

func LongestCommonPrefix

func LongestCommonPrefix(paths []Path) Path

LongestCommonPrefix returns the longest shared Path prefix of all of the paths.

func New

func New(s string) Path

Split cleans and splits the system-delimited filesystem path.

func ToPaths

func ToPaths(paths []string) []Path

ToPaths cleans and splits each of the system-delimited filesystem paths.

func (Path) LessThan

func (p Path) LessThan(o Path) bool

LessThan provides lexicographic ordering of Paths.

func (Path) String

func (p Path) String() string

String returns the properly platform-delimited form of the path.

type PreVisitor

type PreVisitor func(Path) ([]Path, error)

PreVisitor is a single-function pre-order PathVisitor implementation.

func (PreVisitor) Enter

func (p PreVisitor) Enter(dir Path) ([]Path, error)

Enter implements Visitor for PrePathVisitor.

func (PreVisitor) Leave

func (PreVisitor) Leave(Path) error

Leave implements Visitor for PrePathVisitor.

type Visitor

type Visitor interface {
	Enter(dir Path) ([]Path, error) // Preorder, returns the paths of children to visit. Children must be relative to dir.
	Leave(dir Path) error           // Postorder, called after children are visited.
}

Visitor is an interface which visit on the provided path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL