Class: Spoon::FileActions
- Inherits:
-
Object
- Object
- Spoon::FileActions
- Defined in:
- lib/spoon/unix.rb
Defined Under Namespace
Classes: Releaser
Constant Summary collapse
- SIZE =
FFI::Platform.mac? ? FFI.type_size(:pointer) : 128
Instance Attribute Summary collapse
-
#pointer ⇒ Object
readonly
Returns the value of attribute pointer.
Instance Method Summary collapse
- #close(fd) ⇒ Object
- #dup2(fd, newfd) ⇒ Object
-
#initialize ⇒ FileActions
constructor
A new instance of FileActions.
- #open(fd, path, oflag, mode) ⇒ Object
Constructor Details
#initialize ⇒ FileActions
Returns a new instance of FileActions.
22 23 24 25 26 |
# File 'lib/spoon/unix.rb', line 22 def initialize @pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), Releaser) error = LibC.posix_spawn_file_actions_init(@pointer) raise SystemCallError.new("posix_file_actions_init", error) unless error == 0 end |
Instance Attribute Details
#pointer ⇒ Object (readonly)
Returns the value of attribute pointer.
19 20 21 |
# File 'lib/spoon/unix.rb', line 19 def pointer @pointer end |
Instance Method Details
#close(fd) ⇒ Object
41 42 43 44 45 |
# File 'lib/spoon/unix.rb', line 41 def close(fd) error = LibC.posix_spawn_file_actions_addclose(@pointer, fd) raise SystemCallError.new("posix_file_actions_addclose", error) unless error == 0 self end |
#dup2(fd, newfd) ⇒ Object
47 48 49 50 51 |
# File 'lib/spoon/unix.rb', line 47 def dup2(fd, newfd) error = LibC.posix_spawn_file_actions_adddup2(@pointer, fd, newfd) raise SystemCallError.new("posix_file_actions_adddup2", error) unless error == 0 self end |
#open(fd, path, oflag, mode) ⇒ Object
35 36 37 38 39 |
# File 'lib/spoon/unix.rb', line 35 def open(fd, path, oflag, mode) error = LibC.posix_spawn_file_actions_addopen(@pointer, fd, path, oflag, mode) raise SystemCallError.new("posix_file_actions_addopen", error) unless error == 0 self end |