Documentation
¶
Index ¶
- Constants
- func Add(path string, op Op, callback func(string, Op)) error
- func AddRecursive(path string, op Op, cb func(string, Op)) error
- func Close() error
- func Remove(path string) error
- func RemoveRecursive(path string) error
- func SetDefault(fw *FileWatcher)
- func Start() error
- func Stop() error
- type Callback
- type FileWatcher
- func (fw *FileWatcher) Add(path string, op Op, callback Callback) error
- func (fw *FileWatcher) AddRecursive(path string, op Op, cb Callback) error
- func (fw *FileWatcher) Close() error
- func (fw *FileWatcher) Remove(path string) error
- func (fw *FileWatcher) RemoveRecursive(path string) error
- func (fw *FileWatcher) Start() error
- func (fw *FileWatcher) Stop() error
- type Op
Constants ¶
const ( // OpNone none operation OpNone = Op(0) // OpCreate create operation OpCreate = fsnotify.Create // OpWrite write operation OpWrite = fsnotify.Write // OpRemove remove operation OpRemove = fsnotify.Remove // OpRename rename operation OpRename = fsnotify.Rename // OpChmod chmod operation OpChmod = fsnotify.Chmod // OpModifies modifies operations (OpCreate | OpWrite | OpRemove | OpRename) OpModifies = OpCreate | OpWrite | OpRemove | OpRename // OpALL all operations OpALL = Op(0xFFFFFFFF) )
Variables ¶
This section is empty.
Functions ¶
func AddRecursive ¶
AddRecursive add files and all sub-directories under the path to watch
func Close ¶ added in v1.2.3
func Close() error
Close stop file watching go-routine and removes all watches
func RemoveRecursive ¶
RemoveRecursive stops watching the directory and all sub-directories.
func SetDefault ¶ added in v1.2.0
func SetDefault(fw *FileWatcher)
SetDefault set the default FileWatcher instance used by the package-level functions.
Types ¶
type FileWatcher ¶
FileWatcher struct for file watching
func Default ¶
func Default() *FileWatcher
Default returns the default FileWatcher instance used by the package-level functions.
func NewFileWatcher ¶
func NewFileWatcher(delays ...time.Duration) *FileWatcher
NewFileWatcher create a FileWatcher with default 1sec delay. Some editor use create->rename to save file, This could raise 2 OpWrite events continuously, delay some time to prevent duplicated event.
func (*FileWatcher) Add ¶
func (fw *FileWatcher) Add(path string, op Op, callback Callback) error
Add add a file to watch on specified operation op occurred
func (*FileWatcher) AddRecursive ¶
func (fw *FileWatcher) AddRecursive(path string, op Op, cb Callback) error
AddRecursive add files and all sub-directories under the path to watch
func (*FileWatcher) Close ¶ added in v1.2.3
func (fw *FileWatcher) Close() error
Close stop file watching go-routine and removes all watches
func (*FileWatcher) Remove ¶
func (fw *FileWatcher) Remove(path string) error
Remove stop watching the file
func (*FileWatcher) RemoveRecursive ¶
func (fw *FileWatcher) RemoveRecursive(path string) error
RemoveRecursive stops watching the directory and all sub-directories.
func (*FileWatcher) Start ¶
func (fw *FileWatcher) Start() error
Start start file watching go-routine