watcher

package
v0.0.0-...-d0596d9 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2017 License: BSD-3-Clause Imports: 2 Imported by: 0

README

watcher

-- import "github.com/NEU-SNS/ReverseTraceroute/watcher"

Package watcher watches a directory and reports back file system events

Usage

var (
	// ErrWatcherClosed is returned when the watcher is closed while waiting for an event
	ErrWatcherClosed = fmt.Errorf("The watcher was closed")
)
type Event
type Event interface {
	// Name gets the name of the file associated with the event
	Name() string
	// Type gets the event type
	// Currently only create and Remove events are supported
	Type() EventType
}

Event represents a file system event

type EventType
type EventType int

EventType represents a file system event

const (
	// Create is when a file is created
	Create EventType = iota
	// Remove is when a file is removed
	Remove
)
type Watcher
type Watcher interface {
	// Close closes the watcher. The path watched by the watcher is no longer being
	// watched for events
	Close() error
	// GetEvent gets the next file system event. The call will block until an event occurs.
	// The call can be unblocked by closing the channel argument
	GetEvent(chan struct{}) (Event, error)
}

Watcher watches a path

func New
func New(path string) (Watcher, error)

New creates a new watcher which watches the given path

Documentation

Overview

Package watcher watches a directory and reports back file system events

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWatcherClosed is returned when the watcher is closed while waiting for an event
	ErrWatcherClosed = fmt.Errorf("The watcher was closed")
)

Functions

This section is empty.

Types

type Event

type Event interface {
	// Name gets the name of the file associated with the event
	Name() string
	// Type gets the event type
	// Currently only create and Remove events are supported
	Type() EventType
}

Event represents a file system event

type EventType

type EventType int

EventType represents a file system event

const (
	// Create is when a file is created
	Create EventType = iota
	// Remove is when a file is removed
	Remove
)

type Watcher

type Watcher interface {
	// Close closes the watcher. The path watched by the watcher is no longer being
	// watched for events
	Close() error
	// GetEvent gets the next file system event. The call will block until an event occurs.
	// The call can be unblocked by closing the channel argument
	GetEvent(chan struct{}) (Event, error)
}

Watcher watches a path

func New

func New(path string) (Watcher, error)

New creates a new watcher which watches the given path

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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