watcher

package
v4.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package watcher provides an inotify-based approach for watching file system events from a directory recursively.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateEvent

type CreateEvent struct {
	// contains filtered or unexported fields
}

CreateEvent represents the creation of a file or directory.

func (CreateEvent) IsDir

func (ce CreateEvent) IsDir() bool

IsDir returns whether the event item is a directory.

func (CreateEvent) Path

func (ce CreateEvent) Path() string

Path returns the event item's path.

func (CreateEvent) String

func (ce CreateEvent) String() string

func (CreateEvent) WatcherEvent

func (ce CreateEvent) WatcherEvent() string

WatcherEvent returns a string representation of the event.

type DeleteEvent

type DeleteEvent struct {
	// contains filtered or unexported fields
}

DeleteEvent represents the removal of a file or directory.

func (DeleteEvent) IsDir

func (de DeleteEvent) IsDir() bool

IsDir returns whether the event item is a directory.

func (DeleteEvent) Path

func (de DeleteEvent) Path() string

Path returns the event item's path.

func (DeleteEvent) String

func (de DeleteEvent) String() string

func (DeleteEvent) WatcherEvent

func (de DeleteEvent) WatcherEvent() string

WatcherEvent returns a string representation of the event.

type Event

type Event interface {
	fmt.Stringer
	WatcherEvent() string
	IsDir() bool
	Path() string
}

Event is an event emitted by a watcher.

type ModifyEvent

type ModifyEvent struct {
	// contains filtered or unexported fields
}

ModifyEvent represents the modification of a file or directory.

func (ModifyEvent) IsDir

func (me ModifyEvent) IsDir() bool

IsDir returns whether the event item is a directory.

func (ModifyEvent) Path

func (me ModifyEvent) Path() string

Path returns the event item's path.

func (ModifyEvent) String

func (me ModifyEvent) String() string

func (ModifyEvent) WatcherEvent

func (me ModifyEvent) WatcherEvent() string

WatcherEvent returns a string representation of the event.

type RenameEvent

type RenameEvent struct {
	// OldPath can be equal to "" if the old path is from an unwatched directory.
	OldPath string
	// contains filtered or unexported fields
}

RenameEvent represents the moving of a file or directory.

func (RenameEvent) IsDir

func (re RenameEvent) IsDir() bool

IsDir returns whether the event item is a directory.

func (RenameEvent) Path

func (re RenameEvent) Path() string

Path returns the event item's path. Path can be equal to "" if the new path is from an unwatched directory.

func (RenameEvent) String

func (re RenameEvent) String() string

func (RenameEvent) WatcherEvent

func (re RenameEvent) WatcherEvent() string

WatcherEvent returns a string representation of the event.

type W

type W struct {
	// contains filtered or unexported fields
}

W is a watcher for a directory.

func New

func New(dirPath string, ignoreRegExps []*regexp.Regexp) (*W, error)

New creates a watcher for dirPath recursively, ignoring any path that matches at least one of ignoreRegExps. Directory paths matched against ignoreRegExps end with a /.

func (*W) Close

func (w *W) Close() error

Close closes the watcher. If the watcher is already closed, it's a no-op.

func (*W) Errs

func (w *W) Errs() chan error

Errs returns the errors channel.

func (*W) Events

func (w *W) Events() chan Event

Events returns the events channel.

func (*W) Wait

func (w *W) Wait()

Wait blocks until the watcher is closed.

Jump to

Keyboard shortcuts

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