isShellPatternMatch returns whether fullpath matches the shell pattern, as defined by http://golang.org/pkg/path/filepath/#Match. As an additional special case, when the pattern looks like a basename, the last path element of fullpath is also checked against it.
(shellPattern, fullpath string)
| 542 | |
| 543 | // isShellPatternMatch returns whether fullpath matches the shell pattern, as defined by http://golang.org/pkg/path/filepath/#Match. As an additional special case, when the pattern looks like a basename, the last path element of fullpath is also checked against it. |
| 544 | func isShellPatternMatch(shellPattern, fullpath string) bool { |
| 545 | match, _ := filepath.Match(shellPattern, fullpath) |
| 546 | if match { |
| 547 | return true |
| 548 | } |
| 549 | if !strings.Contains(shellPattern, filepathSeparatorString) { |
| 550 | match, _ := filepath.Match(shellPattern, filepath.Base(fullpath)) |
| 551 | if match { |
| 552 | return true |
| 553 | } |
| 554 | } |
| 555 | return false |
| 556 | } |
| 557 | |
| 558 | // hasDirPrefix reports whether the path has the provided directory prefix. |
| 559 | // Both should be absolute paths. |
no test coverage detected