treewatcher

package module
v0.0.0-...-40261e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2014 License: MIT Imports: 3 Imported by: 1

README

treewatcher Build Status GoDoc

Recursive Filesystem Tree Watcher for Go

This is a wrapper around the fsnotify functionality from howeyc/fsnotify.

It exposes a similar interface, with an Event channel and an Error channel. All data read from the fsnotify object is passed through to the client.

When the TreeWatcher sees that a directory was added, it automatically starts watching that directory and all directories under it.

Usage

tw = treewatcher.New()
defer tw.Close()
tw.WatchTree("/tmp")

for {
    select {
    event := <- tw.Event:
        handleEvent(event)
    error := <- tw.Error:
        panic(error)
    }
}

For a real usage example, see dimfeld/simpleblog/fswatcher.go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TreeWatcher

type TreeWatcher struct {
	Event chan *fsnotify.FileEvent
	Error chan error
	// contains filtered or unexported fields
}

TreeWatcher is a wrapper around fsnotify.Watcher that monitors all directories within a tree, and automatically adds watches on newly created directories under the tree. All events from the fsnotify.Watcher are passed through to the TreeWatcher's channels.

func New

func New() (*TreeWatcher, error)

func (*TreeWatcher) Close

func (tw *TreeWatcher) Close()

func (*TreeWatcher) Watch

func (tw *TreeWatcher) Watch(path string) error

func (*TreeWatcher) WatchTree

func (tw *TreeWatcher) WatchTree(path string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL