LICENSE NEWS README TODO
SleepyPenguin Epoll Epoll::IO Ev EvFilt EventFD Inotify Inotify::Event Kevent Kqueue Kqueue::IO Note TimerFD VQ

Methods

::new #add_watch #each #rm_watch #take

class SleepyPenguin::Inotify

Inotify objects are used for monitoring file system events, it can monitor individual files or directories. When a directory is monitored it will return events for the directory itself and all files inside the directory.

Inotify IO objects can be watched using IO.select or Epoll. IO#close may be called on the object when it is no longer needed.

Inotify is available on Linux 2.6.13 or later.

require "sleepy_penguin/sp"
ino = SP::Inotify.new
ino.add_watch("/path/to/foo", :OPEN)
ino.each do |event|
  p event.events # => [ :OPEN ]
end

Public Class Methods

Inotify.new([flags])     -> Inotify IO object source

Flags may be any of the following as an Array of Symbols or Integer mask:

Public Instance Methods

ino.add_watch(path, flags) -> Integer source

Adds a watch on an object specified by its mask, returns an unsigned Integer watch descriptor. flags may be a mask of the following Inotify constants or array of their symbolic names.

When monitoring a directory, the events marked with an asterisk (*) above can occur for files in the directory, in which case the name field in the Event structure identifies the name of the file in the directory.

Shortcut flags:

The following watch attributes may also be included in flags:

ino.each { |event| ... } -> ino source

Yields each Inotify::Event received in a blocking fashion.

ino.rm_watch(watch_descriptor) -> 0 source

Removes a watch based on a watch descriptor Integer. The watch descriptor is a return value given by Inotify#add_watch

ino.take([nonblock]) -> Inotify::Event or nil source

Returns the next Inotify::Event processed. May return nil if nonblock is true.

Parent: IO
Pages Classes Methods


mail archives: https://yhbt.net/sleepy-penguin/
public: sleepy-penguin@yhbt.net
source code: git clone https://yhbt.net/sleepy_penguin.git