Documentation ¶
Index ¶
Constants ¶
const ( IN_ACCESS = uint32(syscall.IN_ACCESS) // File was accessed IN_ATTRIB = uint32(syscall.IN_ATTRIB) // Metadata changed IN_CLOSE_WRITE = uint32(syscall.IN_CLOSE_WRITE) // File opened for writing was closed. IN_CLOSE_NOWRITE = uint32(syscall.IN_CLOSE_NOWRITE) // File or directory not opened for writing was closed. IN_CREATE = uint32(syscall.IN_CREATE) // File/directory created in watched directory IN_DELETE = uint32(syscall.IN_DELETE) // File/directory deleted from watched directory. IN_DELETE_SELF = uint32(syscall.IN_DELETE_SELF) // Watched file/directory was itself deleted. IN_MODIFY = uint32(syscall.IN_MODIFY) // File was modified IN_MOVE_SELF = uint32(syscall.IN_MOVE_SELF) // Watched file/directory was itself moved. IN_MOVED_FROM = uint32(syscall.IN_MOVED_FROM) // Generated for the directory containing the old filename when a file is renamed. IN_MOVED_TO = uint32(syscall.IN_MOVED_TO) // Generated for the directory containing the new filename when a file is renamed. IN_OPEN = uint32(syscall.IN_OPEN) // File or directory was opened. IN_ALL_EVENTS = uint32(syscall.IN_ALL_EVENTS) // bit mask of all of the above events. IN_MOVE = uint32(syscall.IN_MOVE) // Equates to IN_MOVED_FROM | IN_MOVED_TO. IN_CLOSE = uint32(syscall.IN_CLOSE) // Equates to IN_CLOSE_WRITE | IN_CLOSE_NOWRITE. IN_DONT_FOLLOW = uint32(syscall.IN_DONT_FOLLOW) // Don't dereference pathname if it is a symbolic link. IN_EXCL_UNLINK = uint32(syscall.IN_EXCL_UNLINK) // Don't generate events for children if they have been unlinked from the directory. IN_MASK_ADD = uint32(syscall.IN_MASK_ADD) // Add (OR) the events in mask to the watch mask IN_ONESHOT = uint32(syscall.IN_ONESHOT) // Monitor the filesystem object corresponding to pathname for one event, then remove from watch list. IN_ONLYDIR = uint32(syscall.IN_ONLYDIR) // Watch pathname only if it is a directory. IN_IGNORED = uint32(syscall.IN_IGNORED) // Watch was removed explicitly or automatically IN_ISDIR = uint32(syscall.IN_ISDIR) // Subject of this event is a directory. IN_Q_OVERFLOW = uint32(syscall.IN_Q_OVERFLOW) // Event queue overflowed (wd is -1 for this event). IN_UNMOUNT = uint32(syscall.IN_UNMOUNT) // Filesystem containing watched object was unmounted. )
Variables ¶
var TimeoutError = errors.New("Inotify timeout")
Functions ¶
func InMaskToString ¶
Types ¶
type DirWatcher ¶
type DirWatcher struct {
C chan FileEvent
}
DirWatcher recursively watches the given root folder, waiting for file events. Events can be masked by providing fileMask. DirWatcher does not generate events for folders or subfolders.
func NewDirWatcher ¶
NewDirWatcher creates DirWatcher recursively waiting for events in the given root folder and emitting FileEvents in channel C, that correspond to fileMask. Folder events are ignored (having IN_ISDIR set to 1)
type FileEvent ¶
type FileEvent struct { InotifyEvent Eof bool }
FileEvent is the wrapper around InotifyEvent with additional Eof marker. Reading from FileEvents from DirWatcher.C or FileWatcher.C may end with Eof when underlying inotify is closed
type FileWatcher ¶
type FileWatcher struct {
C chan FileEvent
}
FileWatcher waits for events generated by filesystem for a specific list of file paths, including IN_CREATE for not yet existing files and IN_DELETE for removed.
func NewFileWatcher ¶
NewFileWatcher creates FileWatcher with provided inotify mask and list of files to wait events for.
type Inotify ¶
type Inotify struct {
// contains filtered or unexported fields
}
Inotify is the low level wrapper around inotify_init(), inotify_add_watch() and inotify_rm_watch()
func NewInotify ¶
NewInotify creates new inotify instance
func (*Inotify) Read ¶
func (i *Inotify) Read() ([]InotifyEvent, error)
Read reads portion of InotifyEvents and may fail with an error. If no events are available, it will wait forever, until context is cancelled.
func (*Inotify) ReadDeadline ¶
func (i *Inotify) ReadDeadline(deadline time.Time) ([]InotifyEvent, error)
ReadDeadline waits for InotifyEvents until deadline is reached, or context is cancelled. If deadline is reached, TimeoutError is returned.
type InotifyEvent ¶
type InotifyEvent struct { // Watch descriptor Wd uint32 // File or directory name Name string // Contains bits that describe the event that occurred Mask uint32 // Usually 0, but if events (like IN_MOVED_FROM and IN_MOVED_TO) are linked then they will have equal cookie Cookie uint32 }
InotifyEvent is the go representation of inotify_event found in sys/inotify.h
func (InotifyEvent) GoString ¶
func (i InotifyEvent) GoString() string
func (InotifyEvent) String ¶
func (i InotifyEvent) String() string