fsevents

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2019 License: BSD-3-Clause Imports: 10 Imported by: 16

README

FSEvents bindings for Go (macOS)

GoDoc Build Status codecov Reviewed by Hound

FSEvents allows an application to monitor a whole file system or portion of it. FSEvents is only available on macOS.

Warning: This API should be considered unstable.

Contributing

Request features and report bugs using the GitHub Issue Tracker.

fsevents carries the same LICENSE as Go. Contributors retain their copyright, so you need to fill out a short form before we can accept your contribution: Google Individual Contributor License Agreement.

Documentation

Rendered for darwin/amd64

Overview

Package fsevents provides file system notifications on macOS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceForPath

func DeviceForPath(path string) (int32, error)

DeviceForPath returns the device ID for the specified volume.

func EventIDForDeviceBeforeTime

func EventIDForDeviceBeforeTime(dev int32, before time.Time) uint64

EventIDForDeviceBeforeTime returns an event ID before a given time.

func GetDeviceUUID

func GetDeviceUUID(deviceID int32) string

GetDeviceUUID retrieves the UUID required to identify an EventID in the FSEvents database

func GetStreamRefDescription

func GetStreamRefDescription(f FSEventStreamRef) string

GetStreamRefDescription retrieves debugging description information about the StreamRef

func GetStreamRefDeviceID

func GetStreamRefDeviceID(f FSEventStreamRef) int32

GetStreamRefDeviceID retrieves the device ID the stream is watching

func GetStreamRefEventID

func GetStreamRefEventID(f FSEventStreamRef) uint64

GetStreamRefEventID retrieves the last EventID from the ref

func GetStreamRefPaths

func GetStreamRefPaths(f FSEventStreamRef) []string

GetStreamRefPaths returns a copy of the paths being watched by this stream

func LatestEventID

func LatestEventID() uint64

LatestEventID returns the most recently generated event ID, system-wide.

Types

type CFRunLoopRef

type CFRunLoopRef C.CFRunLoopRef

CFRunLoopRef wraps C.CFRunLoopRef

type CreateFlags

type CreateFlags uint32

CreateFlags for creating a New stream.

const (

	// NoDefer sends events on the leading edge (for interactive applications).
	// By default events are delivered after latency seconds (for background tasks).
	NoDefer CreateFlags

	// WatchRoot for a change to occur to a directory along the path being watched.
	WatchRoot

	// IgnoreSelf doesn't send events triggered by the current process (macOS 10.6+).
	IgnoreSelf

	// FileEvents sends events about individual files, generating significantly
	// more events (macOS 10.7+) than directory level notifications.
	FileEvents
)

kFSEventStreamCreateFlag...

type Event

type Event struct {
	Path  string
	Flags EventFlags
	ID    uint64
}

Event represents a single file system notification.

type EventFlags

type EventFlags uint32

EventFlags passed to the FSEventStreamCallback function.

const (
	// MustScanSubDirs indicates that events were coalesced hierarchically.
	MustScanSubDirs EventFlags = 1 << iota
	// UserDropped or KernelDropped is set alongside MustScanSubDirs
	// to help diagnose the problem.
	UserDropped
	KernelDropped

	// EventIDsWrapped indicates the 64-bit event ID counter wrapped around.
	EventIDsWrapped

	// HistoryDone is a sentinel event when retrieving events sinceWhen.
	HistoryDone

	// RootChanged indicates a change to a directory along the path being watched.
	RootChanged

	// Mount for a volume mounted underneath the path being monitored.
	Mount
	// Unmount event occurs after a volume is unmounted.
	Unmount

	ItemCreated
	ItemRemoved
	ItemInodeMetaMod
	ItemRenamed
	ItemModified
	ItemFinderInfoMod
	ItemChangeOwner
	ItemXattrMod
	ItemIsFile
	ItemIsDir
	ItemIsSymlink
)

kFSEventStreamEventFlag...

type EventStream

type EventStream struct {
	Events  chan []Event
	Paths   []string
	Flags   CreateFlags
	EventID uint64
	Resume  bool
	Latency time.Duration
	// syscall represents this with an int32
	Device int32
	// contains filtered or unexported fields
}

EventStream is the primary interface to FSEvents You can provide your own event channel if you wish (or one will be created on Start).

es := &EventStream{Paths: []string{"/tmp"}, Flags: 0}
es.Start()
es.Stop()
...

func (*EventStream) Flush

func (es *EventStream) Flush(sync bool)

Flush events that have occurred but haven't been delivered.

func (*EventStream) Restart

func (es *EventStream) Restart()

Restart listening.

func (*EventStream) Start

func (es *EventStream) Start()

Start listening to an event stream.

func (*EventStream) Stop

func (es *EventStream) Stop()

Stop listening to the event stream.

type FSEventStreamRef

type FSEventStreamRef C.FSEventStreamRef

FSEventStreamRef wraps C.FSEventStreamRef

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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