Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#sysopen
(?::String mode, ?::Integer perm) -> ::Integer
sysopen(mode = 'r', permissions = 0666) → integer
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1320
def sysopen(...) File.sysopen(@path, ...) end
Opens the file at the path in self with the given mode and permissions; returns the integer file descriptor.
If the file is to be readable, it must exist; if the file is to be writable and does not exist, it is created with the given permissions:
Example
pn = Pathname('doc/t.tmp') pn.write('foo') fd = pn.sysopen # => 5 IO.new(fd).close fd = pn.sysopen('w') # => 5 IO.new(fd).close fd = pn.sysopen('r', 0o644) # => 5 IO.new(fd).close pn.delete