Skip invalid filters (windows).
This commit is contained in:
parent
e26955a5bb
commit
78d6d30475
1 changed files with 13 additions and 9 deletions
22
file.go
22
file.go
|
@ -96,10 +96,11 @@ func (f FileFilters) name() {
|
||||||
//
|
//
|
||||||
// First we remove character classes, then escaping. Patterns with literal wildcards are invalid.
|
// First we remove character classes, then escaping. Patterns with literal wildcards are invalid.
|
||||||
// The semicolon is a separator, so we replace it with the single character wildcard.
|
// The semicolon is a separator, so we replace it with the single character wildcard.
|
||||||
// Empty and invalid patterns are ignored.
|
// Empty and invalid filters/patterns are ignored.
|
||||||
func (f FileFilters) simplify() {
|
func (f FileFilters) simplify() {
|
||||||
for i, filter := range f {
|
var i = 0
|
||||||
var n = 0
|
for _, filter := range f {
|
||||||
|
var j = 0
|
||||||
for _, pattern := range filter.Patterns {
|
for _, pattern := range filter.Patterns {
|
||||||
var escape, invalid bool
|
var escape, invalid bool
|
||||||
var buf strings.Builder
|
var buf strings.Builder
|
||||||
|
@ -119,16 +120,19 @@ func (f FileFilters) simplify() {
|
||||||
escape = false
|
escape = false
|
||||||
}
|
}
|
||||||
if buf.Len() > 0 && !invalid {
|
if buf.Len() > 0 && !invalid {
|
||||||
filter.Patterns[n] = buf.String()
|
filter.Patterns[j] = buf.String()
|
||||||
n++
|
j++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if n == 0 {
|
if j > 0 {
|
||||||
f[i].Patterns = nil
|
filter.Patterns = filter.Patterns[:j]
|
||||||
} else {
|
f[i] = filter
|
||||||
f[i].Patterns = filter.Patterns[:n]
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for ; i < len(f); i++ {
|
||||||
|
f[i] = FileFilter{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// macOS types may be specified as extension strings without the leading period,
|
// macOS types may be specified as extension strings without the leading period,
|
||||||
|
|
Loading…
Reference in a new issue