Documentation ¶
Index ¶
- Variables
- type Event
- type FileSystemWatcher
- func (fw *FileSystemWatcher) AddDir(path, pattern string, ops Op, recursive bool) error
- func (fw *FileSystemWatcher) AddFile(path string, ops Op) error
- func (fw *FileSystemWatcher) Close() error
- func (fw *FileSystemWatcher) NotifyEvent(notify func(*Event, error))
- func (fw *FileSystemWatcher) RemoveDir(path string, recursive bool) error
- func (fw *FileSystemWatcher) RemoveFile(path string) error
- func (fw *FileSystemWatcher) WaitEvent() (*Event, error)
- type Op
Constants ¶
This section is empty.
Variables ¶
var ErrWatcherClosed = fmt.Errorf("FileSystemWatcher closed")
ErrWatcherClosed is returned to allow for clean shutting down of a watcher.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { Name string // Relative path to the file or directory. Op Op // File operation that triggered the event. // contains filtered or unexported fields }
Event represents a single file system notification.
type FileSystemWatcher ¶
type FileSystemWatcher struct {
// contains filtered or unexported fields
}
FileSystemWatcher represents a structure used to watch files on the file system.
func NewFileSystemWatcher ¶
func NewFileSystemWatcher() (*FileSystemWatcher, error)
NewFileSystemWatcher returns an initialized *FileSystemWatcher.
func (*FileSystemWatcher) AddDir ¶
func (fw *FileSystemWatcher) AddDir(path, pattern string, ops Op, recursive bool) error
AddDir adds a directory to be watched, returning an error if any. It allows a filter to be specified on which files to watch. It also allows recursive watching.
func (*FileSystemWatcher) AddFile ¶
func (fw *FileSystemWatcher) AddFile(path string, ops Op) error
AddFile adds a file to be watched along with an Op on which to filter events, // returning an error if any.
func (*FileSystemWatcher) Close ¶
func (fw *FileSystemWatcher) Close() error
Close closes the system resources for this FileSystemWatcher
func (*FileSystemWatcher) NotifyEvent ¶
func (fw *FileSystemWatcher) NotifyEvent(notify func(*Event, error))
NotifyEvent accepts a function that takes a *bcnotify.Event and error and calls that function whenever an event or error happens.
func (*FileSystemWatcher) RemoveDir ¶
func (fw *FileSystemWatcher) RemoveDir(path string, recursive bool) error
RemoveDir removes a directory from being watched, returning an error if any. It also allows recursive removal.
func (*FileSystemWatcher) RemoveFile ¶
func (fw *FileSystemWatcher) RemoveFile(path string) error
RemoveFile removes a file from being watched and returns and error if any.
func (*FileSystemWatcher) WaitEvent ¶
func (fw *FileSystemWatcher) WaitEvent() (*Event, error)
WaitEvent blocks and waits until an event or error comes through. This needs to be called in a go routine, probably in a loop.