Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSkip = fmt.Errorf("skip file or folder")
ErrSkip can be returned to indicate that the current file or folder should be skipped from any further traversal.
Functions ¶
func CutPath ¶
CutPath tries to extract the first segment from the path. If the path does not contain a separator, then the returned remainder is empty.
func IsGlob ¶
IsGlob checks whether the specified pattern is a candidate to be a glob. In general, that means it has the glob prefix, which is `*/` . If this method returns true, this does not mean that the glob pattern itself is valid.
func Traverse ¶
func Traverse(root string, callback TraverseFunc)
Traverse attempts to simplify file traversal.
The underlying filepath.WalkDir only works well for directories as root elements. Passing a file as root changes the contract substantially making it hard on the client.
Types ¶
type AbsolutePath ¶
type AbsolutePath = string
AbsolutePath is a string that holds an absolute path.
func ToAbsolutePath ¶
func ToAbsolutePath(path string) (AbsolutePath, error)
ToAbsolutePath converts the specified path to absolute.
type FilterTree ¶
type FilterTree struct {
// contains filtered or unexported fields
}
FilterTree is a data structure that can be used to mark specific filesystem paths as accepted and others as rejected. This can also be achieved through global glob patterns.
The structure then provides a means through which one can test whether a given file path is accepted or rejected by the filter.
func NewFilterTree ¶
func NewFilterTree() *FilterTree
NewFilterTree creates a new empty FilterTree instance.
func (*FilterTree) AcceptGlob ¶
func (t *FilterTree) AcceptGlob(glob string)
AcceptGlob requests that sub-paths of a path segment that matches the specified glob should be accepted.
func (*FilterTree) AcceptPath ¶
func (t *FilterTree) AcceptPath(path AbsolutePath)
AcceptPath requests that the specified path be accepted.
func (*FilterTree) IsAccepted ¶
func (t *FilterTree) IsAccepted(path AbsolutePath) bool
IsAccepted returns whether the specified path is allowed by this filter.
func (*FilterTree) RejectGlob ¶
func (t *FilterTree) RejectGlob(glob string)
RejectGlob requests that sub-paths of a path segment that matches the specified glob should not be accepted.
func (*FilterTree) RejectPath ¶
func (t *FilterTree) RejectPath(path AbsolutePath)
RejectPath requests that the specified path be rejected.
func (*FilterTree) RootPaths ¶
func (t *FilterTree) RootPaths() []AbsolutePath
RootPaths returns the top-most paths that are accepted.