devfs package - code.pfad.fr/devf

import "code.pfad.fr/devf/devfs"

package devfs exposes FS utilities (watch a directory for changes, fallback chain of FS).

Types

type EndRecorder

type EndRecorder func() map[string]struct{}

EndRecorder must be called to get all the files that were accessed during a given period.

type FallbackFS

type FallbackFS []fs.FS

FallbackFS will try to Open a file from each of the underlying fs, until succesful.

func (FallbackFS) Open

func (ffs FallbackFS) Open(name string) (fs.File, error)

type Watcher

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

func WatchDir

func WatchDir(ctx context.Context, dir string, fsEvents chan<- string, maxWatchedDirs int) (*Watcher, error)

WatchDir returns a wrapped [os.DirFS]. Each opened file is added to a watchlist, any write to those file (by external processes) is notified on the provided fsEvents channel.

os.DirFS

At most maxWatchedDirs will be watched (folder with the least recent open/watch event will be evicted if needed).

func (*Watcher) Open

func (f *Watcher) Open(name string) (fs.File, error)

func (*Watcher) StartRecording

func (f *Watcher) StartRecording() EndRecorder

StartRecording returns an EndRecorder which will list all the opened files between the start and the time the EndRecorder was called.

Files

fallbackfs.go
watcher.go

Breadcrumb

code.pfad.fr/devf