Skip to content

Commit fc1b78b

Browse files
committed
move watch creation to a func
1 parent af0d982 commit fc1b78b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

fscanary.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ func main() {
121121
fmt.Println("Adding watch: ", watch.title)
122122
for _,path := range watch.path {
123123
fmt.Println(" Path: ", path)
124-
if err := notify.Watch(path + string(os.PathSeparator) + "...", chNotify, notify.Create|notify.Write|notify.Rename); err != nil {
125-
log.Fatal(err)
126-
}
124+
addWatch(chNotify, path)
127125
}
128126
}
129127
defer notify.Stop(chNotify)
@@ -178,6 +176,12 @@ func load_config(fname string) (gconf global_config, watches []watchPath) {
178176
return gconf, watches
179177
}
180178

179+
func addWatch(ch chan notify.EventInfo, path string) {
180+
if err := notify.Watch(path + string(os.PathSeparator) + "...", ch, notify.Create|notify.Write|notify.Rename); err != nil {
181+
log.Fatal(err)
182+
}
183+
}
184+
181185
/*
182186
* tests a path to determine if it is a directory or other file
183187
*/

0 commit comments

Comments
 (0)