glob

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Glob

func Glob(patterns []string) ([]*FileAsset, []*RegexpInfo, error)

Glob returns files and dirctories that match patterns. Patterns must use slashes, even Windows.

Special chars.

/**/   - match zero or more directories
{a,b}  - match a or b, no spaces
*      - match any non-separator char
?      - match a single non-separator char
**/    - match any directory, start of pattern only
/**    - match any this directory, end of pattern only
!      - removes files from resultset, start of pattern only

func Globexp

func Globexp(glob string) *regexp.Regexp

Globexp builds a regular express from from extended glob pattern and then returns a Regexp object.

func PatternRoot

func PatternRoot(s string) string

PatternRoot gets a real directory root from a pattern. The directory returned is used as the start location for globbing.

Types

type FileAsset

type FileAsset struct {
	os.FileInfo
	// Path to asset
	Path string
}

FileAsset contains file information and path from globbing.

func (*FileAsset) Stat

func (fa *FileAsset) Stat() (*os.FileInfo, error)

Stat updates the stat of this asset.

type RegexpInfo

type RegexpInfo struct {
	Regexp *regexp.Regexp
	Negate bool
	Path   string
	Glob   string
}

RegexpInfo contains additional info about the Regexp created by a glob pattern.

func (*RegexpInfo) MatchString

func (ri *RegexpInfo) MatchString(s string) bool

MatchString matches a string with either a regexp or direct string match

type WatchCriteria

type WatchCriteria struct {
	Items []*WatchCriterion
}

WatchCriteria is the set of criterion to watch one or more glob patterns.

func EffectiveCriteria

func EffectiveCriteria(globs ...string) (*WatchCriteria, error)

EffectiveCriteria is the minimum set of criteria to watch the items in patterns

func (*WatchCriteria) Matches

func (cr *WatchCriteria) Matches(pth string) bool

Matches determines if pth is matched by internal criteria.

func (*WatchCriteria) Roots

func (cr *WatchCriteria) Roots() []string

Roots returns the root paths of all criteria.

type WatchCriterion

type WatchCriterion struct {
	// Root is the root directory to start watching.
	Root string
	// Includes are the regexp for including files
	IncludesRegexp []*regexp.Regexp
	// Excludes are the regexp for excluding files
	ExcludesRegexp []*regexp.Regexp
	Includes       []string
	Excludes       []string
}

WatchCriterion is the criteria needed to test if a file matches a pattern.

Jump to

Keyboard shortcuts

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