fsnotifydeep

package module
v0.0.0-...-cdd42ae Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2015 License: BSD-3-Clause Imports: 4 Imported by: 1

README

Intro

Package fsnotifydeep extends fsnotify to make it work recursively. During an Add, all subdirectories are added as well. For a Remove, the same. As the contents of the monitored directories changes, fsnotify is updated accordingly.

In addition, fsnotifydeep adds a Filter feature to Watchers, allowing the client to specify a function literal that determines if an event should appear on the Events channel or be quietly dropped.

The primary downside of this package is a performance hit. The exact amount will depend on the size of the filesystem under monitor.

Docs

As with all Go packages, documentation can be found on godoc.org. The API is compatible with fsnotify's v1 API. Recursive watching occurs automatically and a filter can be added easily.

Install

 $ go get github.com/traherom/fsnotifydeep

Documentation

Overview

Package fsnotifydeep extends fsnotify to make it work recursively. During an Add, all subdirectories are added as well. For a Remove, the same. As the contents of the monitored directories changes, fsnotify is updated accordingly.

In addition, fsnotifydeep adds a Filter feature to Watchers, allowing the client to specify a function literal that determines if an event should appear on the Events channel or be quietly dropped.

The primary downside of this package is a performance hit. The exact amount will depend on the size of the filesystem under monitor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FsnotifyFilter

type FsnotifyFilter func(fsnotify.Event) bool

An FsnotifyFilter function accepts an event and returns true if that event passes the filter and should be accepted or false if the event should be dropped without notifying the client.

type Watcher

type Watcher struct {
	Events chan fsnotify.Event
	Errors chan error
	// contains filtered or unexported fields
}

Watcher watches a set of files, delivering events to a channel.

func NewWatcher

func NewWatcher() (*Watcher, error)

NewWatcher establishes a new watcher, via fsnotify, begins waiting for events on the filesystem

func (*Watcher) Add

func (w *Watcher) Add(path string) error

Add stops watching the named file or directory.

func (*Watcher) Close

func (w *Watcher) Close() error

Close removes all watches and closes the events channel.

func (*Watcher) Filter

func (w *Watcher) Filter(filter FsnotifyFilter)

Filter adds a filter to watcher, causing only events which pass the filter function to be presented on the Events channel. If a nil filter is used, all events will be published (this is the default for a new Watcher).

func (*Watcher) Remove

func (w *Watcher) Remove(path string) error

Remove stops watching the named file or directory.

Jump to

Keyboard shortcuts

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