From 2e8c2e1c2253b584287830404dc7d7c991f793a3 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Tue, 13 Apr 2021 14:37:10 +0100 Subject: [PATCH] File filter names (windows). --- file.go | 9 +++++++++ file_windows.go | 1 + 2 files changed, 10 insertions(+) diff --git a/file.go b/file.go index 97442c5..ae98daf 100644 --- a/file.go +++ b/file.go @@ -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. diff --git a/file_windows.go b/file_windows.go index cfbd28e..8727206 100644 --- a/file_windows.go +++ b/file_windows.go @@ -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))...)