watchfs

package
v0.0.0-...-214d912 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Interval time.Duration = 500 * time.Millisecond

Functions

func Join

func Join(watches ...*Watch) <-chan Event

Types

type Config

type Config struct {
	Recursive bool
	EventMask uint
	Ignores   []string
	Handler   func(Event)
}

type Event

type Event struct {
	Type    EventType
	Path    string
	OldPath string
	Err     error
	fs.FileInfo
}

func (Event) String

func (e Event) String() string

type EventType

type EventType uint
const (
	EventError EventType = 1 << iota
	EventCreate
	EventWrite
	EventRemove
	EventRename
	EventChmod
	EventMove
)

type FS

type FS struct {
	fs.FS
	// contains filtered or unexported fields
}

func New

func New(fsys fs.FS) *FS

func (*FS) Watch

func (f *FS) Watch(name string, cfg *Config) (*Watch, error)

type Watch

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

func NewWatch

func NewWatch(path string, cfg Config) (*Watch, chan Event, chan bool)

NewWatch is for building your own WatchFS implementation. Use the returned chan Event for sending events and the chan bool for waiting for a close.

func WatchFile

func WatchFile(fsys fs.FS, name string, cfg *Config) (*Watch, error)

func (*Watch) Close

func (w *Watch) Close()

func (*Watch) Iter

func (w *Watch) Iter() <-chan Event

type WatchFS

type WatchFS interface {
	fs.FS
	// Wrapper Filesystems should check their children for implementations before providing their own.
	// Return `errors.ErrUnsupported` to signal that parent Filesystems should use their implementation instead.
	Watch(name string, cfg *Config) (*Watch, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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