Class: FFI::Libfuse::FuseBuf
- Inherits:
-
Object
- Object
- FFI::Libfuse::FuseBuf
- Includes:
- StructWrapper
- Defined in:
- lib/ffi/libfuse/fuse_buf.rb
Overview
Single io buffer
Generic io buffer for I/O, extended attributes, etc...Data may be supplied as a memory pointer or as a file descriptor
Instance Attribute Summary collapse
-
#fd ⇒ Integer
(also: #file_descriptor)
readonly
The file descriptor number.
-
#mem ⇒ FFI::Pointer
(also: #memory)
readonly
The memory in the buffer.
-
#size ⇒ Integer
The size of the buffer.
Attributes included from StructWrapper
Instance Method Summary collapse
-
#fd? ⇒ Boolean
(also: #file_descriptor?)
True if this is a file descriptor buffer.
- #fill(str: nil, mem: str ? FFI::MemoryPointer.from_string(str.to_s) : FFI::Pointer::NULL, size: mem.null? ? 0 : mem.size, fd: -1,, fd_retry: false, pos: nil) ⇒ self
-
#mem? ⇒ Boolean
True if this a memory buffer.
Methods included from StructWrapper
Methods included from StructWrapper::ClassMethods
Methods included from Accessors::ClassMethods
#attr_accessor, #attr_reader, #attr_writer, #ffi_attr_accessor, #ffi_attr_reader, #ffi_attr_reader_method, #ffi_attr_readers, #ffi_attr_writer, #ffi_attr_writer_method, #ffi_attr_writers, #ffi_bitflag_accessor, #ffi_bitflag_reader, #ffi_bitflag_writer, #ffi_public_attr_readers, #ffi_public_attr_writers
Methods included from Accessors
#ffi_attr_fill, #ffi_attr_reader_member, #ffi_attr_writer_member, #inspect, #to_h
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FFI::StructWrapper
Instance Attribute Details
#fd ⇒ Integer (readonly) Also known as: file_descriptor
Returns the file descriptor number.
44 |
# File 'lib/ffi/libfuse/fuse_buf.rb', line 44 alias file_descriptor fd |
#mem ⇒ FFI::Pointer (readonly) Also known as: memory
Returns the memory in the buffer.
39 |
# File 'lib/ffi/libfuse/fuse_buf.rb', line 39 alias memory mem |
#size ⇒ Integer
Returns the size of the buffer.
|
# File 'lib/ffi/libfuse/fuse_buf.rb', line 46
|
Instance Method Details
#fd? ⇒ Boolean Also known as: file_descriptor?
Returns true if this is a file descriptor buffer.
55 56 57 |
# File 'lib/ffi/libfuse/fuse_buf.rb', line 55 def fd? self[:flags].include?(:is_fd) end |
#fill(str: ) ⇒ self #fill(size: ) ⇒ self #fill(mem: , size: mem.size) ⇒ self #fill(fd: , fd_retry: false, size: , pos: 0) ⇒ self
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ffi/libfuse/fuse_buf.rb', line 87 def fill( str: nil, mem: str ? FFI::MemoryPointer.from_string(str.to_s) : FFI::Pointer::NULL, size: mem.null? ? 0 : mem.size, fd: -1, fd_retry: false, pos: nil # rubocop:disable Naming/MethodParameterName ) # Allocate size bytes if we've been given a null pointer mem = FFI::MemoryPointer.new(:char, size, true) if fd == -1 && mem.null? && size.positive? mem.autorelease = to_ptr.autorelease? unless mem.null? self[:size] = size self[:mem] = mem self[:fd] = fd flags = [] flags << :is_fd if fd != -1 flags << :fd_seek if pos flags << :fd_retry if fd_retry self[:flags] = flags self[:pos] = pos || 0 self end |
#mem? ⇒ Boolean
Returns true if this a memory buffer.
50 51 52 |
# File 'lib/ffi/libfuse/fuse_buf.rb', line 50 def mem? !fd? end |