Documentation
¶
Overview ¶
Package watcher implements recursive folder monitoring by wrapping the excellent fsnotify library
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSkip = errors.New("error: skipping file")
ErrSkip is less of an error, but more of a way for path hooks to skip a file or directory.
Functions ¶
This section is empty.
Types ¶
type FilterFileHookFunc ¶
FilterFileHookFunc is a function that is called to filter files during listings. If a file is ok to be listed, nil is returned otherwise ErrSkip is returned.
func RegexFilterHook ¶
func RegexFilterHook(r *regexp.Regexp, useFullPath bool) FilterFileHookFunc
RegexFilterHook is a function that accepts or rejects a file for listing based on whether it's filename or full path matches a regular expression.
type Option ¶
type Option = func(w *Watcher)
func WithIgnoreHiddenFiles ¶
WithIgnoreHiddenFiles sets the watcher to ignore any file or directory that starts with a dot.
func WithOpFilter ¶
WithEventFilter filters which event op types should be returned when an event occurs.
type Watcher ¶
type Watcher struct {
Events chan fsnotify.Event
Errors chan error
Closed chan struct{}
// contains filtered or unexported fields
}
Watcher wraps fsnotify.Watcher. When fsnotify adds recursive watches, you should be able to switch your code to use fsnotify.Watcher
func NewWatcher ¶
NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
func (*Watcher) AddRecursive ¶
AddRecursive starts watching the named directory and all sub-directories.
func (*Watcher) RemoveRecursive ¶
RemoveRecursive stops watching the named directory and all sub-directories.