dfsnotify

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit()

Exit 退出文件监听

func Remove

func Remove(path string) error

Remove 移除监听

func RemoveCallback

func RemoveCallback(callbackId int) error

RemoveCallback 移除回调函数

Types

type Callback

type Callback struct {
	Id   int
	Func func(event *Event)
	Path string
	// contains filtered or unexported fields
}

Callback 回调函数结构体

func Add

func Add(path string, callbackFunc func(event *Event), recursive ...bool) (callback *Callback, err error)

Add 添加路径<path>的监听

func AddOnce

func AddOnce(name, path string, callbackFunc func(event *Event), recursive ...bool) (callback *Callback, err error)

AddOnce 添加路径<path>的监听,使用name区分监听

type Event

type Event struct {
	Path    string
	Op      Op
	Watcher *Watcher
	// contains filtered or unexported fields
}

Event 事件接头体

func (*Event) IsChmod

func (that *Event) IsChmod() bool

IsChmod 是否是文件权限修改事件

func (*Event) IsCreate

func (that *Event) IsCreate() bool

IsCreate 是否是文件创建事件

func (*Event) IsRemove

func (that *Event) IsRemove() bool

IsRemove 是否是文件删除事件

func (*Event) IsRename

func (that *Event) IsRename() bool

IsRename 是否是文件改名事件

func (*Event) IsWrite

func (that *Event) IsWrite() bool

IsWrite 是否是文件写入事件

func (*Event) String

func (that *Event) String() string

返回事件的字符串说明

type Op

type Op uint32

Op 操作标识

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

type Watcher

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

Watcher 监听文件变化

func New

func New() (*Watcher, error)

func (*Watcher) Add

func (that *Watcher) Add(path string, callbackFunc func(event *Event), recursive ...bool) (callback *Callback, err error)

Add 添加文件路径的监视,并且绑定回调函数 如果传入的路径是目录,并且recursive为true,则执行递归监听 recursive默认是true

func (*Watcher) AddOnce

func (that *Watcher) AddOnce(name, path string, callbackFunc func(event *Event), recursive ...bool) (callback *Callback, err error)

AddOnce 使用唯一的<name>添加path的监控,相同name多次监控,只会成功一次

func (*Watcher) Close

func (that *Watcher) Close()

Close 关闭监控器

func (*Watcher) Remove

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

Remove 移除path的监听

func (*Watcher) RemoveCallback

func (that *Watcher) RemoveCallback(callbackId int)

RemoveCallback 删除回调函数

Jump to

Keyboard shortcuts

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