Lines Matching refs:pattern
28 var GlobMultipleRecursiveErr = errors.New("pattern contains multiple **")
29 var GlobLastRecursiveErr = errors.New("pattern ** as last path element")
31 // Glob returns the list of files and directories that match the given pattern
42 func Glob(pattern string, excludes []string) (matches, deps []string, err error) {
43 return startGlob(OsFs, pattern, excludes)
46 func startGlob(fs FileSystem, pattern string, excludes []string) (matches, deps []string, err error) {
47 if filepath.Base(pattern) == "**" {
50 matches, deps, err = glob(fs, pattern, false)
62 // If the pattern has wildcards, we added dependencies on the
65 // If the pattern didn't have wildcards, and didn't find matches, the
71 if !isWild(pattern) {
86 // glob is a recursive helper function to handle globbing each level of the pattern individually,
87 // allowing searched directories to be tracked. Also handles the recursive glob pattern, **.
88 func glob(fs FileSystem, pattern string, hasRecursive bool) (matches, dirs []string, err error) {
89 if !isWild(pattern) {
90 // If there are no wilds in the pattern, check whether the file exists or not.
92 pattern = filepath.Clean(pattern)
93 matches, err = fs.glob(pattern)
99 // Some part of the non-wild pattern didn't exist. Add the last existing directory
103 pattern, _ = saneSplit(pattern)
104 matchDirs, err = fs.glob(pattern)
114 dir, file := saneSplit(pattern)
174 func isWild(pattern string) bool {
175 return strings.ContainsAny(pattern, "*?[")
218 // Match returns true if name matches pattern using the same rules as filepath.Match, but supporting
220 func Match(pattern, name string) (bool, error) {
221 if filepath.Base(pattern) == "**" {
227 pattern, patternFile = saneSplit(pattern)
231 return matchPrefix(pattern, filepath.Join(name, nameFile))
247 // matchPrefix returns true if the beginning of name matches pattern using the same rules as
250 func matchPrefix(pattern, name string) (bool, error) {
251 if len(pattern) > 0 && pattern[0] == '/' {
253 pattern = pattern[1:]
262 patternElem, pattern = saneSplitFirst(pattern)
306 for _, pattern := range patterns {
307 if isWild(pattern) {
308 matches, deps, err = Glob(filepath.Join(prefix, pattern), nil)
315 globedList = append(globedList, filepath.Join(prefix, pattern))
321 // IsGlob returns true if the pattern contains any glob characters (*, ?, or [).
322 func IsGlob(pattern string) bool {
323 return strings.IndexAny(pattern, "*?[") >= 0