gfsnotify

package
v0.0.0-...-882a3c6 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

文件监控. 使用时需要注意的是,一旦一个文件被删除,那么对其的监控将会失效。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(path string, callback func(event *Event)) error

添加对指定文件/目录的监听,并给定回调函数

func Remove

func Remove(path string) error

移除监听

Types

type Event

type Event struct {
	Path string // 文件绝对路径
	Op   Op     // 触发监听的文件操作
}

监听事件对象

func (*Event) IsChmod

func (e *Event) IsChmod() bool

func (*Event) IsCreate

func (e *Event) IsCreate() bool

func (*Event) IsRemove

func (e *Event) IsRemove() bool

func (*Event) IsRename

func (e *Event) IsRename() bool

func (*Event) IsWrite

func (e *Event) IsWrite() bool

type Op

type Op uint32

按位进行识别的操作集合

const (
	CREATE Op = 1 << iota
	WRITE
	REMOVE
	RENAME
	CHMOD
)

type Watcher

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

监听管理对象

func New

func New() (*Watcher, error)

创建监听管理对象

func (*Watcher) Add

func (w *Watcher) Add(path string, callback func(event *Event)) error

添加对指定文件/目录的监听,并给定回调函数

func (*Watcher) Close

func (w *Watcher) Close()

关闭监听管理对象

func (*Watcher) Remove

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

移除监听

Jump to

Keyboard shortcuts

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