watcher

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2014 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package watcher implements filesystem notification,.

Index

Constants

View Source
const (
	// IgnoreThresholdRange is the amount of time in ns to ignore when
	// receiving watch events for the same file
	IgnoreThresholdRange = 50 * 1000000 // convert to ms
)

Variables

This section is empty.

Functions

func DefaultIsIgnorePath

func DefaultIsIgnorePath(path string) bool

DefaultIsIgnorePath checks whether a path is ignored. Currently defaults to hidden files on *nix systems, ie they start with a ".".

Types

type FileEvent

type FileEvent struct {
	*fsnotify.Event
	Name     string
	UnixNano int64
}

FileEvent is a wrapper around github.com/howeyc/fsnotify.FileEvent

type Watcher

type Watcher struct {
	*fsnotify.Watcher
	Event chan *FileEvent
	Error chan error
	//default ignore all file start with "."
	IsIgnorePath func(path string) bool
	//default is nil,if is nil ,error send through Error chan,if is not nil,error handle by this func
	ErrorHandler func(err error)
	// contains filtered or unexported fields
}

Watcher is a wrapper around which adds some additional features:

- recursive directory watch - buffer to even chan - even time

Original work from https://github.com/bronze1man/kmg

func NewWatcher

func NewWatcher(bufferSize int) (watcher *Watcher, err error)

NewWatcher creates an instance of watcher.

func (*Watcher) Close

func (w *Watcher) Close() error

Close closes the watcher channels.

func (*Watcher) GetErrorChan

func (w *Watcher) GetErrorChan() chan error

GetErrorChan gets error chan.

func (*Watcher) GetEventChan

func (w *Watcher) GetEventChan() chan *FileEvent

GetEventChan gets event chan.

func (*Watcher) WatchRecursive

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

WatchRecursive watches a directory recursively. If a dir is created within directory it is also watched.

Jump to

Keyboard shortcuts

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