diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2015-11-03 19:09:03 -0500 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2015-11-03 19:09:03 -0500 |
commit | 0cf23b50244e23a85277350a5393d116f2c4c06f (patch) | |
tree | a82e06479e39a568fa4420e3e53f4d54a7deb7a4 /inotify | |
parent | 1eb4413f868967283487f73c87e906273bab8b9b (diff) |
fold inotify/inutil into inotify
Diffstat (limited to 'inotify')
-rw-r--r-- | inotify/channels.go (renamed from inotify/inutil/inotify_util.go) | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/inotify/inutil/inotify_util.go b/inotify/channels.go index c643e59..737b312 100644 --- a/inotify/inutil/inotify_util.go +++ b/inotify/channels.go @@ -14,37 +14,37 @@ // License along with this manual; if not, see // <http://www.gnu.org/licenses/>. -// Package inutil provides a channel-based interface to inotify. -package inutil +package inotify import ( - "inotify" "os" "syscall" ) +// A Watcher is a wrapper around an (*Inotify) that exposes a +// channel-based interface that is much nicer to work with. type Watcher struct { - Events <-chan inotify.Event + Events <-chan Event Errors <-chan error - events chan<- inotify.Event + events chan<- Event errors chan<- error - in *inotify.Inotify + in *Inotify } -// Wraps inotify.InotifyInit() +// Wraps InotifyInit() func WatcherInit() (*Watcher, error) { - in, err := inotify.InotifyInit() + in, err := InotifyInit() return newWatcher(in, err) } -// Wraps inotify.InotifyInit1() +// Wraps InotifyInit1() func WatcherInit1(flags int) (*Watcher, error) { - in, err := inotify.InotifyInit1(flags &^ inotify.IN_NONBLOCK) + in, err := InotifyInit1(flags &^ IN_NONBLOCK) return newWatcher(in, err) } -func newWatcher(in *inotify.Inotify, err error) (*Watcher, error) { - events := make(chan inotify.Event) +func newWatcher(in *Inotify, err error) (*Watcher, error) { + events := make(chan Event) errors := make(chan error) o := &Watcher{ Events: events, @@ -57,18 +57,18 @@ func newWatcher(in *inotify.Inotify, err error) (*Watcher, error) { return o, err } -// Wraps inotify.Inotify.AddWatch(); adds or modifies a watch. -func (o *Watcher) AddWatch(path string, mask inotify.Mask) (inotify.Wd, error) { +// Wraps Inotify.AddWatch(); adds or modifies a watch. +func (o *Watcher) AddWatch(path string, mask Mask) (Wd, error) { return o.in.AddWatch(path, mask) } -// Wraps inotify.Inotify.RmWatch(); removes a watch. -func (o *Watcher) RmWatch(wd inotify.Wd) error { +// Wraps Inotify.RmWatch(); removes a watch. +func (o *Watcher) RmWatch(wd Wd) error { return o.in.RmWatch(wd) } -// Wraps inotify.Inotify.Close(). Unlike inotify.Inotify.Close(), -// this cannot block. Also unlike inotify.Inotify.Close(), nothing +// Wraps Inotify.Close(). Unlike Inotify.Close(), +// this cannot block. Also unlike Inotify.Close(), nothing // may be received from the channel after this is called. func (o *Watcher) Close() { func() { |