-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodification.go
43 lines (39 loc) · 841 Bytes
/
modification.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package matcher
import (
"github.com/viant/afs/option"
"os"
"time"
)
//Modification represents modification matcher
type Modification struct {
After *time.Time
Before *time.Time
matchers []option.Match
}
//Match matcher parent and info with matcher rules
func (r *Modification) Match(parent string, info os.FileInfo) bool {
if r.After != nil {
if !r.After.Before(info.ModTime()) {
return false
}
}
if r.Before != nil {
if !r.Before.After(info.ModTime()) {
return false
}
}
for i := range r.matchers {
if !r.matchers[i](parent, info) {
return false
}
}
return true
}
//NewModification creates a modification time matcher
func NewModification(before, after *time.Time, matchers ...option.Match) *Modification {
return &Modification{
Before: before,
After: after,
matchers: matchers,
}
}