### Home Classes Methods

### In Files

- lib/ffi/io.rb

### Methods

- ::for_fd
- ::native_read

### Files

- Makefile
- LICENSE
- compile
- configure
- depcomp
- stamp-vti
- install-sh
- libtool-version
- mdate-sh
- missing

### Class/Module Index

Quicksearch

- FFI
- FFI::ArrayType
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::DynamicLibrary
- FFI::DynamicLibrary::Symbol
- FFI::Enum
- FFI::Enums
- FFI::Function
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::ManagedStruct
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::InlineArray
- FFI::Struct::ManagedStructConverter
- FFI::StructByReference
- FFI::StructByValue
- FFI::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Enum
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayoutBuilder
- FFI::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

No matching classes.

# FFI::IO

This module implements a couple of class methods to play with IO.

### Public Class Methods

for_fd(fd, mode = "r") click to toggle source

@param [Integer] fd file decriptor @param [String] mode mode string @return [::IO] Synonym for IO::for_fd.

    # File lib/ffi/io.rb, line 39
    def self.for_fd(fd, mode = "r")
      ::IO.for_fd(fd, mode)
    end

native_read(io, buf, len) click to toggle source

@param [read] io io to read from @param [AbstractMemory] buf destination for data read from `io` @param [nil, Numeric] len maximul number of bytes to read from `io`. If `nil`,

    read until end of file.

@return [Numeric] length really read, in bytes

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.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.