Skip to content

Commit f493ab1

Browse files
committed
added methods to filewatcher
1 parent 4674367 commit f493ab1

1 file changed

Lines changed: 2 additions & 21 deletions

File tree

fs-watcher.go

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type FSWatcher struct {
1818
watcherList *map[string]*watcherObj
1919
mu sync.Mutex
2020
size *uint
21-
config FSWatcherConfig
2221

2322
eventCB []func(path string, event string, op string, isDir bool)
2423

@@ -55,33 +54,17 @@ type FSWatcher struct {
5554
OnAny func(path string, op string)
5655
}
5756

58-
// FSWatcherConfig is the configuration for the FileWatcher
59-
type FSWatcherConfig struct {
60-
// Init will run all On methods when the watcher starts
61-
Init bool
62-
}
63-
6457
type watcherObj struct {
6558
watcher *fsnotify.Watcher
6659
close *bool
6760
}
6861

6962
// FileWatcher creates a new file watcher
70-
func FileWatcher(config ...FSWatcherConfig) *FSWatcher {
71-
var cfg FSWatcherConfig
72-
if len(config) > 0 {
73-
cfg = config[0]
74-
} else {
75-
cfg = FSWatcherConfig{
76-
Init: false,
77-
}
78-
}
79-
63+
func FileWatcher() *FSWatcher {
8064
size := uint(0)
8165
return &FSWatcher{
8266
watcherList: &map[string]*watcherObj{},
8367
size: &size,
84-
config: cfg,
8568
}
8669
}
8770

@@ -99,9 +82,7 @@ func (fw *FSWatcher) WatchDir(root string, nosub ...bool) error {
9982
return err
10083
}
10184

102-
if fw.config.Init {
103-
fw.initDir(root)
104-
}
85+
fw.initDir(root)
10586

10687
runClose := false
10788

0 commit comments

Comments
 (0)