summaryrefslogtreecommitdiffstats
path: root/hugofs/walk.go
diff options
context:
space:
mode:
Diffstat (limited to 'hugofs/walk.go')
-rw-r--r--hugofs/walk.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/hugofs/walk.go b/hugofs/walk.go
index 18667a5fc..391f70a65 100644
--- a/hugofs/walk.go
+++ b/hugofs/walk.go
@@ -53,8 +53,9 @@ type WalkwayConfig struct {
Logger loggers.Logger
// One or both of these may be pre-set.
- Info FileMetaInfo // The start info.
- DirEntries []FileMetaInfo // The start info's dir entries.
+ Info FileMetaInfo // The start info.
+ DirEntries []FileMetaInfo // The start info's dir entries.
+ IgnoreFile func(filename string) bool // Optional
// Will be called in order.
HookPre WalkHook // Optional.
@@ -172,6 +173,17 @@ func (w *Walkway) walk(path string, info FileMetaInfo, dirEntries []FileMetaInfo
}
+ if w.cfg.IgnoreFile != nil {
+ n := 0
+ for _, fi := range dirEntries {
+ if !w.cfg.IgnoreFile(fi.Meta().Filename) {
+ dirEntries[n] = fi
+ n++
+ }
+ }
+ dirEntries = dirEntries[:n]
+ }
+
if w.cfg.HookPre != nil {
var err error
dirEntries, err = w.cfg.HookPre(info, path, dirEntries)