Documentation ¶
Overview ¶
Package watcher implements filesystem notification,.
Index ¶
Constants ¶
View Source
const ( // NONE means no event, initial state. NONE = iota // CREATED means file was created. CREATED // DELETED means file was deleted. DELETED // MODIFIED means file was modified. MODIFIED // PERM means changed permissions PERM // NOEXIST means file does not exist. NOEXIST // NOPERM means no permissions for the file (see const block comment). NOPERM // INVALID means any type of error not represented above. INVALID )
View Source
const ( // IgnoreThresholdRange is the amount of time in ns to ignore when // receiving watch events for the same file IgnoreThresholdRange = 50 * 1000000 // convert to ms // WatchDelay is the time to poll the file system WatchDelay = 1100 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
func DefaultIsIgnorePath ¶
DefaultIsIgnorePath checks whether a path is ignored. Currently defaults to hidden files on *nix systems, ie they start with a ".".
Types ¶
type Watcher ¶
type Watcher struct { *fswatch.Watcher Event chan *FileEvent Error chan error //default ignore all file start with "." IsIgnorePath func(path string) bool //default is nil,if is nil ,error send through Error chan,if is not nil,error handle by this func ErrorHandler func(err error) // contains filtered or unexported fields }
Watcher is a wrapper around which adds some additional features:
- recursive directory watch - buffer to even chan - even time
Original work from https://github.com/bronze1man/kmg
func NewWatcher ¶
NewWatcher creates an instance of watcher.
func (*Watcher) GetErrorChan ¶
GetErrorChan gets error chan.
func (*Watcher) GetEventChan ¶
GetEventChan gets event chan.
func (*Watcher) WatchRecursive ¶
WatchRecursive watches a directory recursively. If a dir is created within directory it is also watched.
Click to show internal directories.
Click to hide internal directories.