-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatcher.go
50 lines (35 loc) · 811 Bytes
/
watcher.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
44
45
46
47
48
49
50
package owl
import (
"time"
"github.com/racg0092/owl/pkg/models"
)
type Watcher struct {
done bool
// How often should the files be checked. Only applies when [Mode] is polling
ShortPollingInterval time.Time
// Mode of wacther
Mode int
// If your watching a single file this is the absolute path. Otherwise the value of [File] is ""
File models.File
// If your watching a directory this is the root directitory
Root string
// List of files being watched
Files []models.File
// Event channels
Events chan Event
// Error channels
Errors chan error
// Directories in the [Root] is any
Directories []string
Done chan int
Verbose bool
}
func (w *Watcher) Close() {
w.done = true
w.Done <- 1
close(w.Events)
close(w.Errors)
}
func (w *Watcher) IsDone() bool {
return w.done
}