filemonitor

package
v0.0.0-...-69c762e Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileChangeCallback

type FileChangeCallback func(event fsnotify.Event) error

FileChangeCallback defines the callback function signature for file change events

type FileGroup

type FileGroup struct {
	ID         string               // Unique identifier
	RootDir    string               // Root directory
	Pattern    *regexp.Regexp       // File matching pattern
	PatternStr string               // Original pattern string for rebuilding
	Blacklist  []string             // Blacklist patterns
	Callbacks  []FileChangeCallback // File change callbacks
	// contains filtered or unexported fields
}

FileGroup represents a group of files with the same processing logic

func NewFileGroup

func NewFileGroup(id, rootDir, pattern string, blacklist []string) (*FileGroup, error)

NewFileGroup creates a new file group

func (*FileGroup) AddCallback

func (fg *FileGroup) AddCallback(callback FileChangeCallback)

AddCallback adds a callback function to the file group

func (*FileGroup) HandleEvent

func (fg *FileGroup) HandleEvent(event fsnotify.Event)

HandleEvent processes a file event and triggers callbacks if the file matches

func (*FileGroup) List

func (fg *FileGroup) List() ([]string, error)

List returns a list of files in the group (real-time scan)

func (*FileGroup) ListMatchingDirectories

func (fg *FileGroup) ListMatchingDirectories() (map[string]bool, error)

ListMatchingDirectories returns directories containing matching files

func (*FileGroup) Match

func (fg *FileGroup) Match(path string) bool

Match checks if a file path matches this group's criteria

func (*FileGroup) RemoveCallback

func (fg *FileGroup) RemoveCallback(callbackToRemove FileChangeCallback) bool

RemoveCallback removes a callback function from the file group

type FileMonitor

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

FileMonitor manages multiple file groups

func NewFileMonitor

func NewFileMonitor() *FileMonitor

NewFileMonitor creates a new file monitor

func (*FileMonitor) AddGroup

func (fm *FileMonitor) AddGroup(group *FileGroup) error

AddGroup adds a new file group

func (*FileMonitor) CreateGroup

func (fm *FileMonitor) CreateGroup(id, rootDir, pattern string, blacklist []string) (*FileGroup, error)

CreateGroup creates and adds a new file group (convenience method)

func (*FileMonitor) GetGroup

func (fm *FileMonitor) GetGroup(id string) (*FileGroup, bool)

GetGroup returns the specified file group

func (*FileMonitor) GetGroups

func (fm *FileMonitor) GetGroups() []*FileGroup

GetGroups returns a list of all file group IDs

func (*FileMonitor) IsRunning

func (fm *FileMonitor) IsRunning() bool

IsRunning returns whether the file monitor is running

func (*FileMonitor) RefreshWatches

func (fm *FileMonitor) RefreshWatches() error

RefreshWatches updates the watched directories based on current matching files

func (*FileMonitor) RemoveGroup

func (fm *FileMonitor) RemoveGroup(id string) error

RemoveGroup removes a file group

func (*FileMonitor) SetBlacklist

func (fm *FileMonitor) SetBlacklist(blacklist []string)

SetBlacklist sets the global directory blacklist

func (*FileMonitor) Start

func (fm *FileMonitor) Start() error

Start starts the file monitor

func (*FileMonitor) Stop

func (fm *FileMonitor) Stop() error

Stop stops the file monitor

func (*FileMonitor) Watcher

func (fm *FileMonitor) Watcher() *fsnotify.Watcher

Jump to

Keyboard shortcuts

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