Documentation
¶
Overview ¶
Package fsnotify provides cross-platform file system change notifications.
Index ¶
Constants ¶
All is the union of every supported Op bit.
Variables ¶
var ( // ErrAlreadyAdded is returned by Add when path is already registered. ErrAlreadyAdded = errors.New("fsnotify: path already added") // ErrNotAdded is returned by Remove when path is not registered. ErrNotAdded = errors.New("fsnotify: path not added") // ErrClosed is returned by methods called on a closed Watcher. ErrClosed = errors.New("fsnotify: watcher closed") // ErrUnsupported is returned by NewWatcher on platforms without a backend. ErrUnsupported = errors.New("fsnotify: platform not supported") )
Sentinel errors returned by Watcher methods.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// Name is the absolute or watcher-relative path of the affected entry.
Name string
// Op is the set of changes that occurred. A single notification may
// carry more than one bit when the underlying OS coalesces events.
Op Op
}
Event represents a single file system change.
type Op ¶
type Op uint32
Op describes a set of file system event types as a bitmask.
const ( // Create indicates a file or directory was created. Create Op = 1 << iota // Write indicates a file's contents were modified. Write // Remove indicates a file or directory was removed. Remove // Rename indicates a file or directory was renamed or moved. Rename // Chmod indicates permissions or attributes changed. Chmod )
type Watcher ¶
type Watcher struct {
// Events delivers change notifications. Closed when Close returns.
Events chan Event
// Errors delivers non-fatal errors from the read loop. Closed when Close returns.
Errors chan error
// contains filtered or unexported fields
}
Watcher monitors registered paths for file system changes via inotify.
func NewWatcher ¶
NewWatcher returns a Watcher backed by Linux inotify.
func (*Watcher) Add ¶
Add registers path with the given event mask. Returns ErrAlreadyAdded if path is already registered, or ErrClosed if the watcher is closed.
func (*Watcher) AddRecursive ¶
AddRecursive registers path and every directory below it. New subdirectories created inside path are watched automatically; subtrees that disappear are dropped via the kernel's IN_IGNORED notification. Returns ErrAlreadyAdded if path is already registered.