mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Update doublestar to fix #38
This commit is contained in:
3
vendor/github.com/bmatcuk/doublestar/.gitignore
generated
vendored
3
vendor/github.com/bmatcuk/doublestar/.gitignore
generated
vendored
@@ -27,3 +27,6 @@ _testmain.go
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
|
||||
# test directory
|
||||
test/
|
||||
|
||||
6
vendor/github.com/bmatcuk/doublestar/.travis.yml
generated
vendored
6
vendor/github.com/bmatcuk/doublestar/.travis.yml
generated
vendored
@@ -1,10 +1,8 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.3
|
||||
- 1.4
|
||||
- 1.5
|
||||
- 1.6
|
||||
- 1.11
|
||||
- 1.12
|
||||
|
||||
before_install:
|
||||
- go get -t -v ./...
|
||||
|
||||
97
vendor/github.com/bmatcuk/doublestar/doublestar.go
generated
vendored
97
vendor/github.com/bmatcuk/doublestar/doublestar.go
generated
vendored
@@ -9,35 +9,49 @@ import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// ErrBadPattern indicates a pattern was malformed.
|
||||
var ErrBadPattern = path.ErrBadPattern
|
||||
|
||||
// Split a path on the given separator, respecting escaping.
|
||||
func splitPathOnSeparator(path string, separator rune) []string {
|
||||
// if the separator is '\\', then we can just split...
|
||||
func splitPathOnSeparator(path string, separator rune) (ret []string) {
|
||||
idx := 0
|
||||
if separator == '\\' {
|
||||
return strings.Split(path, string(separator))
|
||||
// if the separator is '\\', then we can just split...
|
||||
ret = strings.Split(path, string(separator))
|
||||
idx = len(ret)
|
||||
} else {
|
||||
// otherwise, we need to be careful of situations where the separator was escaped
|
||||
cnt := strings.Count(path, string(separator))
|
||||
if cnt == 0 {
|
||||
return []string{path}
|
||||
}
|
||||
|
||||
ret = make([]string, cnt+1)
|
||||
pathlen := len(path)
|
||||
separatorLen := utf8.RuneLen(separator)
|
||||
emptyEnd := false
|
||||
for start := 0; start < pathlen; {
|
||||
end := indexRuneWithEscaping(path[start:], separator)
|
||||
if end == -1 {
|
||||
emptyEnd = false
|
||||
end = pathlen
|
||||
} else {
|
||||
emptyEnd = true
|
||||
end += start
|
||||
}
|
||||
ret[idx] = path[start:end]
|
||||
start = end + separatorLen
|
||||
idx++
|
||||
}
|
||||
|
||||
// If the last rune is a path separator, we need to append an empty string to
|
||||
// represent the last, empty path component. By default, the strings from
|
||||
// make([]string, ...) will be empty, so we just need to icrement the count
|
||||
if emptyEnd {
|
||||
idx++
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise, we need to be careful of situations where the separator was escaped
|
||||
cnt := strings.Count(path, string(separator))
|
||||
if cnt == 0 {
|
||||
return []string{path}
|
||||
}
|
||||
ret := make([]string, cnt+1)
|
||||
pathlen := len(path)
|
||||
separatorLen := utf8.RuneLen(separator)
|
||||
idx := 0
|
||||
for start := 0; start < pathlen; {
|
||||
end := indexRuneWithEscaping(path[start:], separator)
|
||||
if end == -1 {
|
||||
end = pathlen
|
||||
} else {
|
||||
end += start
|
||||
}
|
||||
ret[idx] = path[start:end]
|
||||
start = end + separatorLen
|
||||
idx++
|
||||
}
|
||||
return ret[:idx]
|
||||
}
|
||||
|
||||
@@ -65,8 +79,8 @@ func indexRuneWithEscaping(s string, r rune) int {
|
||||
// { term }
|
||||
// term:
|
||||
// '*' matches any sequence of non-path-separators
|
||||
// '**' matches any sequence of characters, including
|
||||
// path separators.
|
||||
// '**' matches any sequence of characters, including
|
||||
// path separators.
|
||||
// '?' matches any single non-path-separator character
|
||||
// '[' [ '^' ] { character-range } ']'
|
||||
// character class (must be non-empty)
|
||||
@@ -160,13 +174,14 @@ func doMatching(patternComponents, nameComponents []string) (matched bool, err e
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
} else {
|
||||
// try matching components
|
||||
matched, err = matchComponent(patternComponents[patIdx], nameComponents[nameIdx])
|
||||
if !matched || err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// try matching components
|
||||
matched, err = matchComponent(patternComponents[patIdx], nameComponents[nameIdx])
|
||||
if !matched || err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
patIdx++
|
||||
nameIdx++
|
||||
}
|
||||
@@ -194,14 +209,20 @@ func Glob(pattern string) (matches []string, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// On Windows systems, this will return the drive name ('C:'), on others,
|
||||
// it will return an empty string.
|
||||
// On Windows systems, this will return the drive name ('C:') for filesystem
|
||||
// paths, or \\<server>\<share> for UNC paths. On other systems, it will
|
||||
// return an empty string. Since absolute paths on non-Windows systems start
|
||||
// with a slash, patternComponent[0] == volumeName will return true for both
|
||||
// absolute Windows paths and absolute non-Windows paths, but we need a
|
||||
// separate check for UNC paths.
|
||||
volumeName := filepath.VolumeName(pattern)
|
||||
|
||||
// If the first pattern component is equal to the volume name, then the
|
||||
// pattern is an absolute path.
|
||||
if patternComponents[0] == volumeName {
|
||||
return doGlob(fmt.Sprintf("%s%s", volumeName, string(os.PathSeparator)), patternComponents[1:], matches)
|
||||
isWindowsUNC := strings.HasPrefix(pattern, `\\`)
|
||||
if isWindowsUNC || patternComponents[0] == volumeName {
|
||||
startComponentIndex := 1
|
||||
if isWindowsUNC {
|
||||
startComponentIndex = 4
|
||||
}
|
||||
return doGlob(fmt.Sprintf("%s%s", volumeName, string(os.PathSeparator)), patternComponents[startComponentIndex:], matches)
|
||||
}
|
||||
|
||||
// otherwise, it's a relative pattern
|
||||
|
||||
2
vendor/github.com/bmatcuk/doublestar/go.mod
generated
vendored
2
vendor/github.com/bmatcuk/doublestar/go.mod
generated
vendored
@@ -1 +1,3 @@
|
||||
module github.com/bmatcuk/doublestar
|
||||
|
||||
go 1.12
|
||||
|
||||
Reference in New Issue
Block a user