filepathfilter

package
v2.3.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

func New

func New(include, exclude []string) *Filter

func NewFromPatterns

func NewFromPatterns(include, exclude []Pattern) *Filter

func (*Filter) Allows

func (f *Filter) Allows(filename string) bool

func (*Filter) AllowsPattern

func (f *Filter) AllowsPattern(filename string) (pattern string, allowed bool)

AllowsPattern returns whether the given filename is permitted by the inclusion/exclusion rules of this filter, as well as the pattern that either allowed or disallowed that filename.

In special cases, such as a nil `*Filter` receiver, the absence of any patterns, or the given filename not being matched by any pattern, the empty string "" will be returned in place of the pattern.

func (*Filter) Exclude

func (f *Filter) Exclude() []string

Exclude returns the result of calling String() on each Pattern in the exclude set of this *Filter.

func (*Filter) HasPrefix

func (f *Filter) HasPrefix(prefix string) bool

HasPrefix returns whether the given prefix "prefix" is a prefix for all included Patterns, and not a prefix for any excluded Patterns.

func (*Filter) Include

func (f *Filter) Include() []string

Include returns the result of calling String() on each Pattern in the include set of this *Filter.

type Pattern

type Pattern interface {
	// HasPrefix returns whether the receiving Pattern will match a fullpath
	// that contains the prefix "prefix".
	//
	// For instance, if the receiving pattern were to match 'a/b/c.txt',
	// HasPrefix() will return true for:
	//
	//   - 'a', and 'a/'
	//   - 'a/b', and 'a/b/'
	HasPrefix(prefix string) bool

	Match(filename string) bool
	// String returns a string representation (see: regular expressions) of
	// the underlying pattern used to match filenames against this Pattern.
	String() string
}

func NewPattern

func NewPattern(rawpattern string) Pattern

Jump to

Keyboard shortcuts

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