"io/ioutil"
"os"
"path/filepath"
+ "regexp"
"strings"
)
return ft, nil
}
-func getFileNameList(path string) (fields []Field, err error) {
+func getFileNameList(path string, ignoreList []string) (fields []Field, err error) {
files, err := os.ReadDir(path)
if err != nil {
return fields, nil
for _, file := range files {
var fnwi FileNameWithInfo
- if strings.HasPrefix(file.Name(), ".") {
+ if ignoreFile(file.Name(), ignoreList) {
continue
}
var c uint32
for _, f := range dir {
- if !strings.HasPrefix(f.Name(), ".") {
+ if !ignoreFile(f.Name(), ignoreList) {
c += 1
}
}
var c uint32
for _, f := range dir {
- if !strings.HasPrefix(f.Name(), ".") {
+ if !ignoreFile(f.Name(), ignoreList) {
c += 1
}
}
return bytes
}
+
+func ignoreFile(fileName string, ignoreList []string) bool {
+ // skip files that match any regular expression present in the IgnoreFiles list
+ matchIgnoreFilter := 0
+ for _, pattern := range ignoreList {
+ if match, _ := regexp.MatchString(pattern, fileName); match {
+ matchIgnoreFilter += 1
+ }
+ }
+ return matchIgnoreFilter > 0
+}