fsw

package
v0.0.0-...-ada05ea Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2013 License: Apache-2.0 Imports: 6 Imported by: 0

README

fsw

fsw is File System Watcher, it monitoring folders and notify listeners if any thing changed.

Requirements

go 1.1

Usage

go get github.com/howeyc/fsnotify go get github.com/sdming/fsw

Document

TODO:

Getting Started

package main

import (
	"fmt"
	"github.com/sdming/wk/fsw"
	"time"
)

func main() {
	fw, err := fsw.NewFsWatcher(`d:\ddd\a`, `d:\ddd\b`)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("watch", fw)

	fw.Listen(func(e fsw.Event) {
		fmt.Println("event", e)
	})

	<-time.After(time.Minute)
	fw.Close()
	fmt.Println("close")
	<-time.After(time.Minute)
}

Contributing

  • github.com/sdming

License

Apache License 2.0

About

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool = false
View Source
var Logger *log.Logger

Functions

This section is empty.

Types

type Event

type Event struct {
	Name string
	Mode Mode
}

func (Event) String

func (e Event) String() string

String

type FsWatcher

type FsWatcher struct {
	Roots     []string
	Listeners []NotifyFunc
	// contains filtered or unexported fields
}

FsWatcher is file system watcher

func NewFsWatcher

func NewFsWatcher(roots ...string) (*FsWatcher, error)

func (*FsWatcher) Close

func (w *FsWatcher) Close()

Close stop watch

func (*FsWatcher) Listen

func (w *FsWatcher) Listen(fn NotifyFunc)

Listen register a event listener

func (*FsWatcher) String

func (w *FsWatcher) String() string

String

func (*FsWatcher) Watch

func (w *FsWatcher) Watch(name string) error

Watch add file or dir to watch list

type Mode

type Mode int
const (
	Create Mode = 1 << (2 * iota)
	Modify
	Delete
	Rename
)

type NotifyFunc

type NotifyFunc func(e Event)

Jump to

Keyboard shortcuts

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