files

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownFile = errors.New("unknown file name")
	ErrFileTracked = errors.New("file already tracked")
)

Functions

This section is empty.

Types

type Event

type Event struct {
	Name string
	Op   fsnotify.Op
}

func (Event) Type

func (e Event) Type() EventType

type EventType

type EventType string
const (
	EventTypeUnknown EventType = "unknown"
	EventTypeChmod   EventType = "chmod"
	EventTypeCreate  EventType = "create"
	EventTypeRemove  EventType = "remove"
	EventTypeRename  EventType = "rename"
	EventTypeWrite   EventType = "write"
)

type FileInfo

type FileInfo struct {
	fs.FileInfo

	FileType      FileType
	WasDeleted    bool // This is to track the deletion of initial files. New files will be removed from the map with Delete()
	Writes        int64
	PreSwapWrites int64 // Writes that occurred before editor swaps (not counted in final total)
	PendingSwap   bool  // True if file has a pending delete that might be part of an editor swap
}

func (FileInfo) IsInitial

func (f FileInfo) IsInitial() bool

type FileMap

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

func NewFileMap

func NewFileMap() *FileMap

func (*FileMap) AddFile

func (f *FileMap) AddFile(name string, info FileInfo) error

func (*FileMap) AddSwapWrite

func (f *FileMap) AddSwapWrite(name string) error

AddSwapWrite records a write from an editor swap (delete+create pair). It also clears any writes that occurred just before the swap to avoid double-counting.

func (*FileMap) AddWrite

func (f *FileMap) AddWrite(name string) error

func (*FileMap) Delete

func (f *FileMap) Delete(name string) error

func (*FileMap) DeletedFiles

func (f *FileMap) DeletedFiles() []string

func (*FileMap) FilePathsByBase

func (f *FileMap) FilePathsByBase(name string) []string

func (*FileMap) FilesCreated

func (f *FileMap) FilesCreated() int64

func (*FileMap) FilesDeleted

func (f *FileMap) FilesDeleted() int64

func (*FileMap) Get

func (f *FileMap) Get(name string) (FileInfo, error)

func (*FileMap) Has

func (f *FileMap) Has(name string) bool

func (*FileMap) IsInitial

func (f *FileMap) IsInitial(name string) bool

func (*FileMap) MarkPendingSwap

func (f *FileMap) MarkPendingSwap(name string)

MarkPendingSwap marks a file as potentially being swapped by an editor. This prevents writes from being counted until we know if a swap occurred.

func (*FileMap) NewFiles

func (f *FileMap) NewFiles() []string

func (*FileMap) WrittenFiles

func (f *FileMap) WrittenFiles() map[string]int64

type FileType

type FileType string
const (
	FileTypeInitial FileType = "initial"
	FileTypeNew     FileType = "new"
)

type Monitor

type Monitor struct {
	Events chan Event
	// contains filtered or unexported fields
}

func NewMonitor

func NewMonitor(opts *MonitorOpts) (*Monitor, error)

func (*Monitor) Close

func (m *Monitor) Close()

func (*Monitor) FileMap

func (m *Monitor) FileMap() *FileMap

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context)

func (*Monitor) Stats

func (m *Monitor) Stats(final bool) *Stats

func (*Monitor) WatchDirRecursive

func (m *Monitor) WatchDirRecursive(path string, initial bool) error

func (*Monitor) WatchFile

func (m *Monitor) WatchFile(path string, initial bool) error

type MonitorOpts

type MonitorOpts struct {
	RootPath    string
	WatchRoot   bool
	TrackWrites bool
}

func (*MonitorOpts) OK

func (m *MonitorOpts) OK() error

type Stats

type Stats struct {
	NumFilesCreated int64
	NumFilesDeleted int64
	NewFiles        []string
	DeletedFiles    []string
	WrittenFiles    map[string]int64
}

Jump to

Keyboard shortcuts

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