Module: FFI::IO

Defined in:
lib/ffi/io.rb

Class Method Summary collapse

Class Method Details

.for_fd(fd, mode = "r") ⇒ Object



3
4
5
# File 'lib/ffi/io.rb', line 3

def self.for_fd(fd, mode = "r")
  ::IO.for_fd(fd, mode)
end

.native_read(io, buf, len) ⇒ Object

A version of IO#read that reads into a native buffer

This will be optimized at some future time to eliminate the double copy



12
13
14
15
16
17
# File 'lib/ffi/io.rb', line 12

def self.native_read(io, buf, len)
  tmp = io.read(len)
  return -1 unless tmp
  buf.put_bytes(0, tmp)
  tmp.length
end