class INotify::Notifier

def readpartial(size)

Same as IO#readpartial, or as close as we need.
def readpartial(size)
  buffer = FFI::MemoryPointer.new(:char, size)
  size_read = Native.read(fd, buffer, size)
  return buffer.read_string(size_read) if size_read >= 0
  raise SystemCallError.new("Error reading inotify events" +
    case FFI.errno
    when Errno::EAGAIN::Errno; ": no data available for non-blocking I/O"
    when Errno::EBADF::Errno; ": invalid or closed file descriptor"
    when Errno::EFAULT::Errno; ": invalid buffer"
    when Errno::EINVAL::Errno; ": invalid file descriptor"
    when Errno::EIO::Errno; ": I/O error"
    when Errno::EISDIR::Errno; ": file descriptor is a directory"
    else; ""
    end,
    FFI.errno)
end