fsmonitor

package module
v0.0.0-...-1cae2d6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2015 License: MIT Imports: 3 Imported by: 0

README

Fsmonit

Simple wrapper around fsnotify to monitor changes in files and folders (including subdirectories created after monitoring has started).

Example:

package main

import (
	"github.com/romanoff/fsmonitor"
	"fmt"
	"log"
	)
func main() {
	watcher, err := fsmonitor.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}
	err = watcher.Watch("/tmp/foo")
	if err != nil {
		log.Fatal(err)
	}
	for {
		select {
		case ev := <-watcher.Event:
			fmt.Println("event:", ev)
		case err := <-watcher.Error:
			fmt.Println("error:", err)
		}
	}
}

There is also an option to skip certain folders (like .git for example):

	watcher, err := fsmonitor.NewWatcherWithSkipFolders([]string{".git"})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

type Watcher struct {
	Events      chan *fsnotify.Event
	Error       chan error
	SkipFolders []string
	// contains filtered or unexported fields
}

Watcher is the struct handling the watching of file system events over a recursive directory tree.

func NewWatcher

func NewWatcher() (*Watcher, error)

NewWatcher initializes a new watcher which is able to recursively scan the directory structure.

func NewWatcherWithSkipFolders

func NewWatcherWithSkipFolders(skipFolders []string) (*Watcher, error)

NewWatcherWithSkipFolders initializes a new watcher capable of watching for file system events of a recursive directory structure.

func (*Watcher) Close

func (w *Watcher) Close() error

Close stops the internal watcher.

func (*Watcher) IsClosed

func (w *Watcher) IsClosed() bool

IsClose returns if the watcher has been closed.

func (*Watcher) Watch

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

Watch starts watching the given path and all it's subdirectories for file system changes.

Jump to

Keyboard shortcuts

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