Class: KQueue::Watcher::File

Inherits:
KQueue::Watcher show all
Defined in:
lib/rb-kqueue/watcher/file.rb

Overview

The KQueue::Watcher subclass for events fired when a file changes. File events are watched via Queue#watch_file.

Instance Attribute Summary collapse

Attributes inherited from KQueue::Watcher

#queue

Class Method Summary collapse

Methods inherited from KQueue::Watcher

#add!, #delete!, #disable!, #enable!

Instance Attribute Details

#pathString (readonly)

The path to the file being watched.

Returns:

  • (String)


9
10
11
# File 'lib/rb-kqueue/watcher/file.rb', line 9

def path
  @path
end

Class Method Details

.finalizer(fd, path) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rb-kqueue/watcher/file.rb', line 44

def self.finalizer(fd, path)
  lambda do |id=nil|
    next unless Native.close(fd) < 0
    raise SystemCallError.new(
      "Failed to close file #{path}" +
      case FFI.errno
    when Errno::EBADF::Errno; ": Invalid file descriptor."
    when Errno::EINTR::Errno; ": Closing interrupted."
    when Errno::EIO::Errno; ": IO error."
    else; ""
    end,
    FFI.errno)
  end
end