Module: FFI::IO
- Defined in:
- lib/ffi/io.rb
Overview
This module implements a couple of class methods to play with IO.
Class Method Summary (collapse)
-
+ (::IO) for_fd(fd, mode = "r")
Synonym for IO::for_fd.
-
+ (Numeric) native_read(io, buf, len)
A version of IO#read that reads data from an IO and put then into a native buffer.
Class Method Details
+ (::IO) for_fd(fd, mode = "r")
Synonym for IO::for_fd.
29 30 31 |
# File 'lib/ffi/io.rb', line 29 def self.for_fd(fd, mode = "r") ::IO.for_fd(fd, mode) end |
+ (Numeric) native_read(io, buf, len)
A version of IO#read that reads data from an IO and put then into a native buffer.
This will be optimized at some future time to eliminate the double copy.
43 44 45 46 47 48 |
# File 'lib/ffi/io.rb', line 43 def self.native_read(io, buf, len) tmp = io.read(len) return -1 unless tmp buf.put_bytes(0, tmp) tmp.length end |