Implement FileWatcher
This commit is contained in:
36
internal/file_watcher.go
Normal file
36
internal/file_watcher.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
// File event mask constants.
|
||||
const (
|
||||
FileEventCreated = 1 << iota
|
||||
FileEventModified
|
||||
FileEventDeleted
|
||||
)
|
||||
|
||||
// FileEvent represents an event on a watched file.
|
||||
type FileEvent struct {
|
||||
Name string
|
||||
Mask int
|
||||
}
|
||||
|
||||
// ErrFileEventQueueOverflow is returned when the file event queue has overflowed.
|
||||
var ErrFileEventQueueOverflow = errors.New("file event queue overflow")
|
||||
|
||||
// FileWatcher represents a watcher of file events.
|
||||
type FileWatcher interface {
|
||||
Open() error
|
||||
Close() error
|
||||
|
||||
// Returns a channel of events for watched files.
|
||||
Events() <-chan FileEvent
|
||||
|
||||
// Adds a specific file to be watched.
|
||||
Watch(filename string) error
|
||||
|
||||
// Removes a specific file from being watched.
|
||||
Unwatch(filename string) error
|
||||
}
|
||||
Reference in New Issue
Block a user