File filter names (windows).

This commit is contained in:
Nuno Cruces 2021-04-13 14:37:10 +01:00
parent 2bb3f4747e
commit 2e8c2e1c22
2 changed files with 10 additions and 0 deletions

View file

@ -85,6 +85,15 @@ func (f FileFilters) apply(o *options) {
o.fileFilters = append(o.fileFilters, f...)
}
// Windows' patterns need a name.
func (f FileFilters) name() {
for i, filter := range f {
if filter.Name == "" {
f[i].Name = strings.Join(filter.Patterns, " ")
}
}
}
// Windows' patterns are case insensitive, don't support character classes or escaping.
// First we remove character classes, then escaping. Patterns with literal wildcards are invalid (match nothing).
// The semicolon is a separator, so we replace it with the single character wildcard.

View file

@ -363,6 +363,7 @@ func initDirNameExt(filename string, name []uint16) (dir *uint16, ext *uint16) {
func initFilters(filters FileFilters) []uint16 {
filters.simplify()
filters.name()
var res []uint16
for _, f := range filters {
res = append(res, utf16.Encode([]rune(f.Name))...)