Class FChange::Notifier
In: lib/vendor/windows/lib/rb-fchange/notifier.rb
Parent: Object

Notifier wraps a single instance of FChange. It‘s possible to have more than one instance, but usually unnecessary.

@example

  # Create the notifier
  notifier = FChange::Notifier.new

  # Run this callback whenever the file path/to/foo.txt is read
  notifier.watch("path/to/foo/", :all_events) do
    puts "foo was accessed!"
  end

  # Nothing happens until you run the notifier!
  notifier.run

Methods

add_watcher   close   new   process   read_events   run   stop   watch  

Constants

INFINITE = 0xFFFFFFFF  
WAIT_OBJECT_0 = 0x00000000  

Attributes

dwChangeHandles  [R] 
lp_dwChangeHandles  [R] 
watchers  [R]  A hash from {Watcher} ids to the instances themselves.

@private @return [{Fixnum => Watcher}]

Public Class methods

Creates a new {Notifier}.

@return [Notifier]

Public Instance methods

Adds a new {Watcher} to the queue.

Blocks until there are one or more filesystem events that this notifier has watchers registered for. Once there are events, the appropriate callbacks are called and this function returns.

@see run

Blocks until there are one or more filesystem events that this notifier has watchers registered for. Once there are events, returns their {Event} objects.

@private

Starts the notifier watching for filesystem events. Blocks until \{stop} is called.

@see process

Stop watching for filesystem events. That is, if we‘re in a \{run} loop, exit out as soon as we finish handling the events.

Watches a file or directory for changes, calling the callback when there are. This is only activated once \{process} or \{run} is called.

**Note that by default, this does not recursively watch subdirectories of the watched directory**. To do so, use the `:recursive` flag.

`:recursive` : Recursively watch any subdirectories that are created.

@param path [String] The path to the file or directory @param flags [Array<Symbol>] Which events to watch for @yield [event] A block that will be called

  whenever one of the specified events occur

@yieldparam event [Event] The Event object containing information

  about the event that occured

@return [Watcher] A Watcher set up to watch this path for these events @raise [SystemCallError] if the file or directory can‘t be watched,

  e.g. if the file isn't found, read access is denied,
  or the flags don't contain any events

[Validate]