module FFI::IO

Public Class Methods

for_fd(fd, mode = "r") click to toggle source
# File lib/ffi/io.rb, line 23
def self.for_fd(fd, mode = "r")
  ::IO.for_fd(fd, mode)
end
native_read(io, buf, len) click to toggle source

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

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

# File lib/ffi/io.rb, line 32
def self.native_read(io, buf, len)
  tmp = io.read(len)
  return -1 unless tmp
  buf.put_bytes(0, tmp)
  tmp.length
end