inotify

package
v0.0.0-...-97d2b70 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package inotify provides a platform-independent interface for file system notifications.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package recursive_inotify implements recursive folder monitoring by wrapping the excellent inotify library

Index

Constants

This section is empty.

Variables

View Source
var ErrEventOverflow = errors.New("inotify queue overflow")

Common errors that can be reported by a watcher

Functions

This section is empty.

Types

type Event

type Event struct {
	Name string // Relative path to the file or directory.
	Op   Op     // File operation that triggered the event.
}

Event represents a single file system notification.

func (Event) String

func (e Event) String() string

String returns a string representation of the event in the form "file: REMOVE|WRITE|..."

type Op

type Op uint32

Op describes a set of file operations.

const (
	Create Op = 1 << iota
	Write
	Remove
	Rename
	Chmod
	Open
)

These are the generalized file operations that can trigger a notification.

func (Op) String

func (op Op) String() string

type RWatcher

type RWatcher struct {
	Events chan Event
	Errors chan error
	// contains filtered or unexported fields
}

RWatcher wraps inotify.Watcher. When inotify adds recursive watches, you should be able to switch your code to use inotify.Watcher

func NewRWatcher

func NewRWatcher() (*RWatcher, error)

NewRWatcher establishes a new watcher with the underlying OS and begins waiting for events.

func (*RWatcher) Add

func (m *RWatcher) Add(name string) error

Add starts watching the named file or directory (non-recursively).

func (*RWatcher) AddRecursive

func (m *RWatcher) AddRecursive(name string) error

AddRecursive starts watching the named directory and all sub-directories.

func (*RWatcher) Close

func (m *RWatcher) Close() error

Close removes all watches and closes the events channel.

func (*RWatcher) Remove

func (m *RWatcher) Remove(name string) error

Remove stops watching the the named file or directory (non-recursively).

func (*RWatcher) RemoveRecursive

func (m *RWatcher) RemoveRecursive(name string) error

RemoveRecursive stops watching the named directory and all sub-directories.

type Watcher

type Watcher struct {
	Events chan Event
	Errors chan error
	// contains filtered or unexported fields
}

Watcher watches a set of files, delivering events to a channel.

func NewWatcher

func NewWatcher() (*Watcher, error)

NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.

func (*Watcher) Add

func (w *Watcher) Add(name string) error

Add starts watching the named file or directory (non-recursively).

func (*Watcher) Close

func (w *Watcher) Close() error

Close removes all watches and closes the events channel.

func (*Watcher) Remove

func (w *Watcher) Remove(name string) error

Remove stops watching the named file or directory (non-recursively).

Jump to

Keyboard shortcuts

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