mirror of
https://github.com/go-task/task.git
synced 2026-07-02 17:08:45 +00:00
Update dependencies
This commit is contained in:
45
vendor/github.com/mattn/go-zglob/zglob.go
generated
vendored
45
vendor/github.com/mattn/go-zglob/zglob.go
generated
vendored
@@ -18,12 +18,13 @@ var (
|
||||
)
|
||||
|
||||
type zenv struct {
|
||||
dre *regexp.Regexp
|
||||
fre *regexp.Regexp
|
||||
root string
|
||||
dre *regexp.Regexp
|
||||
fre *regexp.Regexp
|
||||
pattern string
|
||||
root string
|
||||
}
|
||||
|
||||
func makePattern(pattern string) (*zenv, error) {
|
||||
func New(pattern string) (*zenv, error) {
|
||||
globmask := ""
|
||||
root := ""
|
||||
for n, i := range strings.Split(filepath.ToSlash(pattern), "/") {
|
||||
@@ -56,9 +57,10 @@ func makePattern(pattern string) (*zenv, error) {
|
||||
}
|
||||
if root == "" {
|
||||
return &zenv{
|
||||
dre: nil,
|
||||
fre: nil,
|
||||
root: "",
|
||||
dre: nil,
|
||||
fre: nil,
|
||||
pattern: pattern,
|
||||
root: "",
|
||||
}, nil
|
||||
}
|
||||
if globmask == "" {
|
||||
@@ -106,9 +108,10 @@ func makePattern(pattern string) (*zenv, error) {
|
||||
filemask = "(?i:" + filemask + ")"
|
||||
}
|
||||
return &zenv{
|
||||
dre: regexp.MustCompile("^" + dirmask),
|
||||
fre: regexp.MustCompile("^" + filemask + "$"),
|
||||
root: filepath.Clean(root),
|
||||
dre: regexp.MustCompile("^" + dirmask),
|
||||
fre: regexp.MustCompile("^" + filemask + "$"),
|
||||
pattern: pattern,
|
||||
root: filepath.Clean(root),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -121,7 +124,7 @@ func GlobFollowSymlinks(pattern string) ([]string, error) {
|
||||
}
|
||||
|
||||
func glob(pattern string, followSymlinks bool) ([]string, error) {
|
||||
zenv, err := makePattern(pattern)
|
||||
zenv, err := New(pattern)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -180,22 +183,26 @@ func glob(pattern string, followSymlinks bool) ([]string, error) {
|
||||
}
|
||||
|
||||
func Match(pattern, name string) (matched bool, err error) {
|
||||
zenv, err := makePattern(pattern)
|
||||
zenv, err := New(pattern)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if zenv.root == "" {
|
||||
return pattern == name, nil
|
||||
return zenv.Match(name), nil
|
||||
}
|
||||
|
||||
func (z *zenv) Match(name string) bool {
|
||||
if z.root == "" {
|
||||
return z.pattern == name
|
||||
}
|
||||
|
||||
name = filepath.ToSlash(name)
|
||||
|
||||
if name == "." || len(name) <= len(zenv.root) {
|
||||
return false, nil
|
||||
if name == "." || len(name) <= len(z.root) {
|
||||
return false
|
||||
}
|
||||
|
||||
if zenv.fre.MatchString(name) {
|
||||
return true, nil
|
||||
if z.fre.MatchString(name) {
|
||||
return true
|
||||
}
|
||||
return false, nil
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user