Documentation
¶
Overview ¶
Package watcher implements recursive folder monitoring by wrapping the excellent fsnotify library
Index ¶
- Constants
- Variables
- func GetEtagByReader(reader Reader, size int64) string
- type Event
- type FilterFileHookFunc
- type Option
- type Reader
- type Watcher
- func (m *Watcher) Add(name string) error
- func (m *Watcher) AddRecursive(name string) error
- func (m *Watcher) Close() error
- func (m *Watcher) Notify(handlerKey string)
- func (m *Watcher) Remove(name string) error
- func (m *Watcher) RemoveRecursive(name string) error
- func (m *Watcher) Start(name string) error
Constants ¶
const (
BlockSize int64 = 4194304
)
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 ¶
func GetEtagByReader ¶ added in v1.0.2
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 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.