Documentation
¶
Index ¶
Constants ¶
const ( NONE = iota // No event, initial state. CREATED // File was created. DELETED // File was deleted. MODIFIED // File was modified. PERM // Changed permissions NOEXIST // File does not exist. NOPERM // No permissions for the file (see const block comment). INVALID // Any type of error not represented above. )
These values represent the events fswatch knows about. fswatch uses a stat(2) call to look up file information; a file will only have a NOPERM event if the parent directory has no search permission (i.e. parent directory doesn't have executable permissions for the current user).
Variables ¶
var NotificationBufLen = 16
NotificationBufLen is the number of notifications that should be buffered in the channel.
var WatchDelay time.Duration
WatchDelay is the duration between path scans. It defaults to 100ms.
Functions ¶
This section is empty.
Types ¶
type Notification ¶
Notification represents a file state change. The Path field indicates the file that was changed, while last event corresponds to one of the event type constants.
type Watcher ¶
type Watcher struct { // ignoreFn is used to ignore paths IgnorePathFn func(path string) bool // contains filtered or unexported fields }
Watcher represents a file system watcher. It should be initialised with NewWatcher or NewAutoWatcher, and started with Watcher.Start().
func NewAutoWatcher ¶
NewAutoWatcher initialises a new Watcher with an initial set of paths. It behaves the same as NewWatcher, except it will automatically add files created in directories it is watching, including adding any subdirectories.
func NewWatcher ¶
NewWatcher initialises a new Watcher with an initial set of paths. It does not start listening, and this Watcher will not automatically add files created under any directories it is watching.
func (*Watcher) Add ¶
Add method takes a variable number of string arguments and adds those files to the watch list, returning the number of files added.
func (*Watcher) Start ¶
func (w *Watcher) Start() <-chan *Notification
Start begins watching the files, sending notifications when files change. It returns a channel that notifications are sent on.
func (*Watcher) State ¶
func (w *Watcher) State() (state []Notification)
State returns a slice of Notifications representing the files being watched and their last event.