Package org.jruby
Class RubyIO
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyIO
- All Implemented Interfaces:
Closeable
,Flushable
,Serializable
,AutoCloseable
,Cloneable
,Comparable<IRubyObject>
,InstanceVariables
,InternalVariables
,IRubyObject
,CoreObjectType
,IOEncodable
- Direct Known Subclasses:
FileDescriptorIO
,RubyBasicSocket
,RubyFile
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
static class
static class
Represents a Ruby IO::TimeoutErrorError as a throwable Java exception.Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Data
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer
Nested classes/interfaces inherited from interface org.jruby.util.io.IOEncodable
IOEncodable.ConvConfig
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final int
protected OpenFile
static final ByteList
protected boolean
If the stream is being used for popen, we don't want to destroy the process when we close the stream.Fields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
Fields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStamp
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
-
Constructor Summary
ConstructorsConstructorDescriptionRubyIO
(Ruby runtime, InputStream inputStream) RubyIO
(Ruby runtime, OutputStream outputStream) RubyIO
(Ruby runtime, OutputStream outputStream, boolean autoclose) RubyIO
(Ruby runtime, RubyClass cls, ShellLauncher.POpenProcess process, RubyHash options, IOOptions ioOptions) Deprecated.Deprecated.RubyIO
(Ruby runtime, ShellLauncher.POpenProcess process, IOOptions ioOptions) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBlockingThread
(RubyThread thread) Add a thread to the list of blocking threads for this IO.advise
(ThreadContext context, IRubyObject[] argv) autoclose
(ThreadContext context) autoclose_set
(ThreadContext context, IRubyObject autoclose) binmode()
Deprecated.binmode
(ThreadContext context) static IRubyObject
binread
(ThreadContext context, IRubyObject recv, IRubyObject[] args) binread is just like read, except it doesn't take options and it forces mode to be "rb:ASCII-8BIT"static IRubyObject
binwrite
(ThreadContext context, IRubyObject recv, IRubyObject[] args) bytes
(ThreadContext context, Block block) Deprecated.chars
(ThreadContext context, Block block) Deprecated.static RubyArray
checkExecEnv
(ThreadContext context, RubyHash hash) Deprecated.static void
checkExecOptions
(IRubyObject options) Deprecated.protected void
checkLength
(ThreadContext context, int len) static void
checkPopenOptions
(IRubyObject options) Deprecated.static void
checkSpawnOptions
(IRubyObject options) Deprecated.static ChannelFD
cloexecOpen
(Ruby runtime, RubyIO.Sysopen data) final void
close()
close
(ThreadContext context) Closes all open resources for the IO.close_on_exec_p
(ThreadContext context) close_on_exec_set
(ThreadContext context, IRubyObject arg) close_read
(ThreadContext context) close_write
(ThreadContext context) closed_p
(ThreadContext context) codepoints
(ThreadContext context, Block block) Deprecated.static RubyIO
convertToIO
(ThreadContext context, IRubyObject obj) static IRubyObject
copy_stream
(ThreadContext context, IRubyObject recv, IRubyObject[] args) static IRubyObject
copy_stream
(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) static IRubyObject
copy_stream
(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) static RubyClass
createIOClass
(ThreadContext context, RubyClass Object, RubyModule Enumerable) protected static int
doRead
(ThreadContext context, OpenFile fptr, byte[] buffer, int start, int len) doReadNonblock
(ThreadContext context, IRubyObject[] args, boolean exception) doReadNonblock
(ThreadContext context, IRubyObject arg0, boolean exception) doReadNonblock
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, boolean exception) doReadNonblock
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, boolean exception) doWriteNonblock
(ThreadContext context, IRubyObject[] argv, boolean useException) Deprecated.each
(ThreadContext context, Block block) each
(ThreadContext context, IRubyObject[] args, Block block) each
(ThreadContext context, IRubyObject arg0, Block block) each
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) each
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) each_byte
(ThreadContext context, Block block) each_byteInternal
(ThreadContext context, Block block) Invoke a block for each byte.each_char
(ThreadContext context, Block block) each_charInternal
(ThreadContext context, Block block) each_codepoint
(ThreadContext context, Block block) each_line
(ThreadContext context, Block block) each_line
(ThreadContext context, IRubyObject[] args, Block block) each_line
(ThreadContext context, IRubyObject arg0, Block block) each_line
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) each_line
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) static IRubyObject
ensureYieldClose
(ThreadContext context, IRubyObject port, Block block) static IRubyObject
ensureYieldClosePipes
(ThreadContext context, IRubyObject obj, RubyIO r, RubyIO w, Block block) eof_p
(ThreadContext context) external_encoding
(ThreadContext context) static void
failIfDirectory
(Ruby runtime, RubyString pathStr) fcntl
(ThreadContext context, IRubyObject cmd) fcntl
(ThreadContext context, IRubyObject cmd, IRubyObject arg) fileno
(ThreadContext context) void
flush()
flush
(ThreadContext context) Flushes the IO output stream.protected RubyIO
flushRaw
(ThreadContext context, boolean sync) static IRubyObject
for_fd
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) static IRubyObject
foreach
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) fsync
(ThreadContext context) boolean
boolean
getBOM()
getbyte
(ThreadContext context) Read a byte.int
getByte
(ThreadContext context) getc()
Deprecated.getc
(ThreadContext context) Get the underlying channel from this IO object.int
org.jcodings.Encoding
getEnc()
org.jcodings.Encoding
getEnc2()
org.jcodings.Encoding
static ModeFlags
getIOModes
(Ruby runtime, String modesString) Deprecated.static int
getIOModesIntFromString
(Ruby runtime, String modesString) Deprecated.Deprecated.Deprecated.getline
(ThreadContext context, IRubyObject separator) getline
(ThreadContext context, IRubyObject separator, long limit) getline using logic of gets.getline
(ThreadContext context, ByteList separator) Deprecated.getline
(ThreadContext context, ByteList separator, long limit) Deprecated.This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.getPath()
org.jcodings.Encoding
gets
(ThreadContext context) Read a line.gets
(ThreadContext context, IRubyObject arg) gets
(ThreadContext context, IRubyObject rs, IRubyObject limit_arg) gets
(ThreadContext context, IRubyObject rs, IRubyObject limit_arg, IRubyObject opt) boolean
getSync()
initialize
(ThreadContext context, IRubyObject fileNumber, Block unused) initialize
(ThreadContext context, IRubyObject fileNumber, IRubyObject second, Block unused) initialize
(ThreadContext context, IRubyObject fileNumber, IRubyObject modeValue, IRubyObject options, Block unused) initialize_copy
(ThreadContext context, IRubyObject _io) Initializes this object as a copy of the original, that is the parameter to this object.inspect
(ThreadContext context) Returns a string containing a human-readable representation of obj.internal_encoding
(ThreadContext context) protected static IRubyObject
ioClose
(ThreadContext context, IRubyObject io) ioctl
(ThreadContext context, IRubyObject[] args) static IRubyObject
ioOpen
(ThreadContext context, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) Deprecated.static IRubyObject
ioOpen
(ThreadContext context, IRubyObject recv, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) static IRubyObject
ioStaticWrite
(ThreadContext context, IRubyObject recv, IRubyObject[] argv, boolean binary) boolean
boolean
isClosed()
Is this IO closed MRI: rb_io_closedlineno
(ThreadContext context) Returns the current line number.lineno_set
(ThreadContext context, IRubyObject newLineNumber) Sets the current line number.lines
(ThreadContext context, Block block) Deprecated.final OpenFile
static IRubyObject
newInstance
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) static RubyIO
static IOOptions
newIOOptions
(Ruby runtime, int mode) static IOOptions
newIOOptions
(Ruby runtime, long mode) static IOOptions
newIOOptions
(Ruby runtime, String mode) static IOOptions
newIOOptions
(Ruby runtime, IOOptions oldFlags, int orOflags) static IOOptions
newIOOptions
(Ruby runtime, ModeFlags modeFlags) static ModeFlags
newModeFlags
(Ruby runtime, int mode) static ModeFlags
newModeFlags
(Ruby runtime, long mode) static ModeFlags
newModeFlags
(Ruby runtime, String mode) static void
obliterateProcess
(Process process) Try for around 1s to destroy the child process.op_append
(ThreadContext context, IRubyObject anObject) rb_io_addstrop_binmode
(ThreadContext context) static IRubyObject
open
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) protected IOOptions
path
(ThreadContext context) pid
(ThreadContext context) Return the process id (pid) of the process this IO object spawned.static IRubyObject
pipe
(ThreadContext context, IRubyObject recv) static IRubyObject
pipe
(ThreadContext context, IRubyObject klass, Block block) static IRubyObject
pipe
(ThreadContext context, IRubyObject klass, IRubyObject[] argv, Block block) Deprecated.static IRubyObject
pipe
(ThreadContext context, IRubyObject klass, IRubyObject arg0, Block block) static IRubyObject
pipe
(ThreadContext context, IRubyObject klass, IRubyObject arg0, IRubyObject arg1, Block block) static IRubyObject
pipe
(ThreadContext context, IRubyObject klass, IRubyObject v1, IRubyObject v2, IRubyObject opt, Block block) static IRubyObject
popen
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) static IRubyObject
popen3
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Deprecated.static IRubyObject
popen4
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Deprecated.static org.jruby.RubyIO.POpenTuple
popenSpecial
(ThreadContext context, IRubyObject[] args) Deprecated.pos
(ThreadContext context) pos_set
(ThreadContext context, IRubyObject offset) pread
(ThreadContext context, IRubyObject len, IRubyObject offset) pread
(ThreadContext context, IRubyObject _length, IRubyObject _from, IRubyObject str) static RubyIO
static RubyIO
print
(ThreadContext context) print
(ThreadContext context, IRubyObject arg0) print
(ThreadContext context, IRubyObject[] args) Print some objects to the stream.print
(ThreadContext context, IRubyObject arg0, IRubyObject arg1) static IRubyObject
print
(ThreadContext context, IRubyObject out, IRubyObject[] args) Print some objects to the stream.print
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) static IRubyObject
print0
(ThreadContext context, IRubyObject out) static IRubyObject
print1
(ThreadContext context, IRubyObject out, IRubyObject arg1) static IRubyObject
print2
(ThreadContext context, IRubyObject out, IRubyObject arg0, IRubyObject arg1) static IRubyObject
print3
(ThreadContext context, IRubyObject out, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) printf
(ThreadContext context, IRubyObject[] args) static IRubyObject
printf
(ThreadContext context, IRubyObject out, IRubyObject[] args) putc
(ThreadContext context, IRubyObject ch) static IRubyObject
putc
(ThreadContext context, IRubyObject maybeIO, IRubyObject object) puts
(ThreadContext context) puts
(ThreadContext context, IRubyObject arg0) puts
(ThreadContext context, IRubyObject[] args) puts
(ThreadContext context, IRubyObject arg0, IRubyObject arg1) static IRubyObject
puts
(ThreadContext context, IRubyObject maybeIO, IRubyObject... args) puts
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) static IRubyObject
puts0
(ThreadContext context, IRubyObject maybeIO) static IRubyObject
puts1
(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0) static IRubyObject
puts2
(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1) static IRubyObject
puts3
(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) pwrite
(ThreadContext context, IRubyObject str, IRubyObject offset) protected IRubyObject
rbIoClose
(ThreadContext context) read
(IRubyObject[] args) Deprecated.read
(ThreadContext context) Read all available bytes.int
read
(ThreadContext context, byte[] buffer, int start, int len) Read into the given buffer starting from start and reading len bytes.read
(ThreadContext context, IRubyObject length) Read length bytes.read
(ThreadContext context, IRubyObject[] args) read
(ThreadContext context, IRubyObject length, IRubyObject maybeStr) Read into the given buffer (or create a new one) reading length bytes.static IRubyObject
read
(ThreadContext context, IRubyObject recv, IRubyObject[] args) static IRubyObject
read
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) read_nonblock
(ThreadContext context, IRubyObject arg0) read_nonblock
(ThreadContext context, IRubyObject[] args) Deprecated.read_nonblock
(ThreadContext context, IRubyObject arg0, IRubyObject arg1) read_nonblock
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) readbyte
(ThreadContext context) readchar()
Deprecated.readchar
(ThreadContext context) Read a char.readline
(ThreadContext context) Read a line.readline
(ThreadContext context, IRubyObject separator) readline
(ThreadContext context, IRubyObject[] args) Deprecated.readline
(ThreadContext context, IRubyObject separator, IRubyObject limit) readline
(ThreadContext context, IRubyObject separator, IRubyObject limit, IRubyObject opts) readlines
(ThreadContext context) readlines
(ThreadContext context, IRubyObject arg0) readlines
(ThreadContext context, IRubyObject[] args) readlines
(ThreadContext context, IRubyObject arg0, IRubyObject arg1) static IRubyObject
readlines
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) readlines
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) readpartial
(ThreadContext context, IRubyObject arg0) readpartial
(ThreadContext context, IRubyObject[] args) Deprecated.readpartial
(ThreadContext context, IRubyObject arg0, IRubyObject arg1) void
removeBlockingThread
(RubyThread thread) Remove a thread from the list of blocking threads for this IO.reopen
(ThreadContext context, IRubyObject[] args) protected RubyIO
reopenIO
(ThreadContext context, RubyIO nfile) rewind
(ThreadContext context) seek
(ThreadContext context, IRubyObject off) seek
(ThreadContext context, IRubyObject[] args) seek
(ThreadContext context, IRubyObject off, IRubyObject whence) static IRubyObject
select
(ThreadContext context, IRubyObject recv, IRubyObject[] argv) static IRubyObject
select_static
(ThreadContext context, Ruby runtime, IRubyObject[] args) Deprecated.set_encoding
(ThreadContext context, IRubyObject encodingObj) set_encoding
(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding) set_encoding
(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding, IRubyObject options) set_encoding_by_bom
(ThreadContext context) protected RubyIO
void
setAutoclose
(boolean autoclose) void
setBlocking
(boolean blocking) void
setBOM
(boolean bom) void
setEcflags
(int ecflags) void
setEcopts
(IRubyObject ecopts) void
setEnc
(org.jcodings.Encoding enc) void
setEnc2
(org.jcodings.Encoding enc2) void
setEncoding
(ThreadContext context, IRubyObject v1, IRubyObject v2, IRubyObject opt) protected void
void
setSync
(boolean sync) stat
(ThreadContext context) sync
(ThreadContext context) Returns the current sync mode.sync_set
(IRubyObject sync) Deprecated.Usesync_set(ThreadContext, IRubyObject)
instead.sync_set
(ThreadContext context, IRubyObject sync) Sets the current sync mode.protected static ChannelFD
static IRubyObject
sysopen
(IRubyObject recv, IRubyObject[] args, Block block) Deprecated.static IRubyObject
sysopen
(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block block) sysread
(ThreadContext context, IRubyObject _length) sysread
(ThreadContext context, IRubyObject[] args) Deprecated.sysread
(ThreadContext context, IRubyObject _length, IRubyObject _str) sysseek
(ThreadContext context, IRubyObject[] args) syswrite
(ThreadContext context, IRubyObject str) to_io()
<T> T
Convert the object to the specified Java class, if possible.toString()
The default toString method is just a wrapper that calls the Ruby "to_s" method.static IRubyObject
tryConvert
(ThreadContext context, IRubyObject recv, IRubyObject arg) tty_p
(ThreadContext context) ungetbyte
(ThreadContext context, IRubyObject b) ungetc
(ThreadContext context, IRubyObject c) protected IOOptions
updateIOOptionsFromOptions
(ThreadContext context, RubyHash options, IOOptions ioOptions) See http://ruby-doc.org/core-1.9.3/IO.html#method-c-new for the format of modes in optionswait
(ThreadContext context, IRubyObject[] argv) static IRubyObject
wait
(ThreadContext context, IRubyObject _io, IRubyObject[] argv) wait_readable
(ThreadContext context, IRubyObject[] argv) static IRubyObject
wait_readable
(ThreadContext context, IRubyObject _io, IRubyObject[] argv) wait_writable
(ThreadContext context, IRubyObject[] argv) waits until input available or timed out and returns self, or nil when EOF reached.static IRubyObject
wait_writable
(ThreadContext context, IRubyObject _io, IRubyObject[] argv) waits until input available or timed out and returns self, or nil when EOF reached.int
write
(byte[] bytes, int start, int length, org.jcodings.Encoding encoding) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)
but context will be retrieved and nosync defaults to false.int
write
(byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)
but context will be retrieved.int
write
(byte[] bytes, org.jcodings.Encoding encoding) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)
but context will be retrieved nosync defaults to false, and the entire byte array will be written.void
write
(int bite) Same aswrite(ThreadContext, byte)
but context will be retrieved.final void
write
(ThreadContext context, byte ch) Write a single byte to this IO's write target but do not return the number of bytes written (it will be 1).int
write
(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding) Write the given range of bytes to this IO.int
write
(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) Write the given range of bytes to this IO.final IRubyObject
write
(ThreadContext context, int ch) Write a single byte to this IO's write target.write
(ThreadContext context, IRubyObject str) Ruby method IO#write(str), equivalent to io_write_m.write
(ThreadContext context, IRubyObject[] args) Ruby method IO#write(str, ...), equivalent to io_write_m.write
(ThreadContext context, IRubyObject str, boolean nosync) Write the given range of bytes to this IO's write target.static IRubyObject
write
(ThreadContext context, IRubyObject maybeIO, IRubyObject str) static IRubyObject
write
(ThreadContext context, IRubyObject recv, IRubyObject[] argv) static IRubyObject
write
(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1) protected static IRubyObject
write
(ThreadContext context, IRubyObject maybeIO, ByteList byteList) protected static IRubyObject
write
(ThreadContext context, IRubyObject maybeIO, ByteList byteList, IRubyObject sep) write_nonblock
(ThreadContext context, IRubyObject arg0) write_nonblock
(ThreadContext context, IRubyObject[] argv) Deprecated.write_nonblock
(ThreadContext context, IRubyObject arg0, IRubyObject arg1) write2
(ThreadContext context, IRubyObject arg0, IRubyObject arg1) Ruby method IO#write(str, ...), equivalent to io_write_m.write3
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Ruby method IO#write(str, ...), equivalent to io_write_m.static IRubyObject
writeStatic
(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block unusedBlock) Deprecated.static IRubyObject
writev
(ThreadContext context, IRubyObject io) static IRubyObject
writev
(ThreadContext context, IRubyObject io, IRubyObject arg0) static IRubyObject
writev
(ThreadContext context, IRubyObject io, IRubyObject[] args) static IRubyObject
writev
(ThreadContext context, IRubyObject io, IRubyObject arg0, IRubyObject arg1) static IRubyObject
writev
(ThreadContext context, IRubyObject io, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, dig, dig1, dig2, eqlInternal, equalInternal, equals, finishObjectClass, hashCode, inspect, op_eqq, puts, specificEval, toRubyString
Methods inherited from class org.jruby.RubyBasicObject
addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dup, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, eql_p, equal_p, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_cmp, op_equal, op_match, op_not, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbClone, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, to_s, to_s, trust, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariables
-
Field Details
-
PARAGRAPH_SEPARATOR
-
CLOSED_STREAM_MSG
- See Also:
-
FD_CLOEXEC
public static final int FD_CLOEXEC- See Also:
-
openFile
-
popenSpecial
protected boolean popenSpecialIf the stream is being used for popen, we don't want to destroy the process when we close the stream.
-
-
Constructor Details
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
Deprecated. -
RubyIO
@Deprecated public RubyIO(Ruby runtime, RubyClass cls, ShellLauncher.POpenProcess process, RubyHash options, IOOptions ioOptions) Deprecated.
-
-
Method Details
-
prepStdio
-
prepStdio
-
newIO
-
getOpenFile
-
getOpenFileChecked
-
getOpenFileInitialized
-
getNativeClassIndex
Description copied from class:RubyObject
This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are. Will generally return a value from org.jruby.runtime.ClassIndex- Specified by:
getNativeClassIndex
in interfaceCoreObjectType
- Overrides:
getNativeClassIndex
in classRubyObject
- Returns:
- the ClassIndex of the native type this object was constructed from
- See Also:
-
createIOClass
public static RubyClass createIOClass(ThreadContext context, RubyClass Object, RubyModule Enumerable) -
getOutStream
-
getInStream
-
getChannel
Get the underlying channel from this IO object. Note that IO buffers data internally, so the channel returned here may have been read into those buffers. If the channel and the IO are both being used at the same time, the stream will get out of sync.- Returns:
- the underlying channel for this IO
-
reopenIO
-
reopen
-
getline
-
getline
getline using logic of gets. If limit is -1 then read unlimited amount. -
getEnc
public org.jcodings.Encoding getEnc()- Specified by:
getEnc
in interfaceIOEncodable
-
getReadEncoding
public org.jcodings.Encoding getReadEncoding() -
getEnc2
public org.jcodings.Encoding getEnc2()- Specified by:
getEnc2
in interfaceIOEncodable
-
getInputEncoding
public org.jcodings.Encoding getInputEncoding() -
newInstance
public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
for_fd
public static IRubyObject for_fd(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
initialize
-
initialize
public IRubyObject initialize(ThreadContext context, IRubyObject fileNumber, IRubyObject second, Block unused) -
initialize
public IRubyObject initialize(ThreadContext context, IRubyObject fileNumber, IRubyObject modeValue, IRubyObject options, Block unused) -
parseIOOptions
-
external_encoding
-
internal_encoding
-
set_encoding
-
set_encoding
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding) -
set_encoding
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding, IRubyObject options) -
set_encoding_by_bom
-
setEncoding
-
open
public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
ensureYieldClose
-
sysopen
Deprecated. -
sysopen
public static IRubyObject sysopen(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block block) -
sysopen
-
cloexecOpen
-
isAutoclose
public boolean isAutoclose() -
setAutoclose
public void setAutoclose(boolean autoclose) -
autoclose
-
autoclose_set
-
binmode
Deprecated.Usebinmode(ThreadContext)
instead.- Returns:
-
binmode
-
op_binmode
-
syswrite
-
write_nonblock
-
write_nonblock
-
GetWriteIO
-
write
Ruby method IO#write(str), equivalent to io_write_m.- Parameters:
context
- the current contextstr
- the string to write
-
write2
Ruby method IO#write(str, ...), equivalent to io_write_m.- Parameters:
context
- the current contextarg0
- the first string to writearg1
- the second string to write
-
write3
public IRubyObject write3(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Ruby method IO#write(str, ...), equivalent to io_write_m.- Parameters:
context
- the current contextarg0
- the first string to writearg1
- the second string to writearg2
- the third string to write
-
write
Ruby method IO#write(str, ...), equivalent to io_write_m.- Parameters:
context
- the current contextargs
- the strings to write
-
write
Write a single byte to this IO's write target.- Parameters:
context
- the current contextch
- the byte to write, as an int- Returns:
- the count of bytes written
-
write
Write a single byte to this IO's write target but do not return the number of bytes written (it will be 1). This version does not dig out any wrapped write IO (bytes will be written to this IO).- Parameters:
context
- the current contextch
- the byte to write, as an int
-
write
Write the given range of bytes to this IO's write target. Equivalent to io_write.- Parameters:
context
- the current contextstr
- the string to writenosync
- whether to write without syncing- Returns:
- the count of bytes written
-
write
public int write(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding) Write the given range of bytes to this IO. Equivalent to io_write_m with source bytes and no digging out any wrapped write IO (bytes will be written to this IO).- Parameters:
context
- the current contextbytes
- the bytes to writestart
- start offset for writinglength
- length to writeencoding
- encoding of the bytes (will not be verified)- Returns:
- the count of bytes written
-
write
public int write(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) Write the given range of bytes to this IO. Equivalent to io_write with source bytes and no digging out any wrapped write IO (bytes will be written to this IO.- Parameters:
context
- the current contextbytes
- the bytes to writestart
- start offset for writinglength
- length to writeencoding
- encoding of the bytes (will not be verified)nosync
- whether to write without syncing- Returns:
- the count of bytes written
-
write
public int write(byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)
but context will be retrieved. Heavy use should retrieve context once and call the original method to avoid thread-local overhead.- Parameters:
bytes
- the bytes to writestart
- start offset for writinglength
- length to writeencoding
- encoding of the bytes (will not be verified)nosync
- whether to write without syncing- Returns:
- the count of bytes written
-
write
public int write(byte[] bytes, int start, int length, org.jcodings.Encoding encoding) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)
but context will be retrieved and nosync defaults to false. Heavy use should retrieve context once and call the original method to avoid thread-local overhead.- Parameters:
bytes
- the bytes to writestart
- start offset for writinglength
- length to writeencoding
- encoding of the bytes (will not be verified)- Returns:
- the count of bytes written
-
write
public int write(byte[] bytes, org.jcodings.Encoding encoding) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)
but context will be retrieved nosync defaults to false, and the entire byte array will be written. Heavy use should retrieve context once and call the original method to avoid thread-local overhead.- Parameters:
bytes
- the bytes to writeencoding
- encoding of the bytes (will not be verified)- Returns:
- the count of bytes written
-
write
public void write(int bite) Same aswrite(ThreadContext, byte)
but context will be retrieved. Heavy use should retrieve context once and call the original method to avoid thread-local overhead.- Parameters:
bite
- the byte to write, as an int
-
op_append
rb_io_addstr -
fileno
-
lineno
Returns the current line number.- Returns:
- the current line number.
-
lineno_set
Sets the current line number.- Parameters:
newLineNumber
- The new line number.
-
sync
Returns the current sync mode. MRI: rb_io_sync- Returns:
- the current sync mode.
-
pid
Return the process id (pid) of the process this IO object spawned. If no process exists (popen was not called), then nil is returned. This is not how it appears to be defined but ruby 1.8 works this way.
- Returns:
- the pid or nil
-
pos
-
pos_set
-
print
Print some objects to the stream. -
print
-
print
-
print
-
print
public IRubyObject print(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
print
Print some objects to the stream. MRI: rb_io_print -
print0
-
print1
-
print2
public static IRubyObject print2(ThreadContext context, IRubyObject out, IRubyObject arg0, IRubyObject arg1) -
print3
public static IRubyObject print3(ThreadContext context, IRubyObject out, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
printf
-
printf
-
putc
-
putc
-
seek
-
seek
-
seek
-
sysseek
-
rewind
-
fsync
-
sync_set
Deprecated.Usesync_set(ThreadContext, IRubyObject)
instead.- Parameters:
sync
-- Returns:
-
sync_set
Sets the current sync mode. MRI: rb_io_set_sync- Parameters:
sync
- The new sync mode.
-
setSync
public void setSync(boolean sync) -
getSync
public boolean getSync() -
eof_p
-
tty_p
-
initialize_copy
Description copied from class:RubyBasicObject
Initializes this object as a copy of the original, that is the parameter to this object. Will make sure that the argument actually has the same real class as this object. It shouldn't be possible to initialize an object with something totally different.- Overrides:
initialize_copy
in classRubyBasicObject
- Parameters:
context
- the thread context_io
- the original- Returns:
- a copy unless the same thing
-
closed_p
-
isClosed
public boolean isClosed()Is this IO closed MRI: rb_io_closed- Returns:
- true if closed
-
close
Closes all open resources for the IO. It also removes it from our magical all open file descriptor pool.
- Returns:
- The IO. Returns nil if the IO was already closed. MRI: rb_io_close_m
-
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
ioClose
-
rbIoClose
-
close_write
-
close_read
-
close_on_exec_set
-
close_on_exec_p
-
flush
Flushes the IO output stream. MRI: rb_io_flush- Returns:
- The IO.
-
flush
public void flush() -
flushRaw
-
gets
Read a line. -
gets
-
gets
-
gets
public IRubyObject gets(ThreadContext context, IRubyObject rs, IRubyObject limit_arg, IRubyObject opt) -
getBlocking
public boolean getBlocking() -
setBlocking
public void setBlocking(boolean blocking) -
fcntl
-
fcntl
-
ioctl
-
puts
-
puts
-
puts
-
puts
public IRubyObject puts(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
puts
-
puts0
-
puts1
-
puts2
public static IRubyObject puts2(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1) -
puts3
public static IRubyObject puts3(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
puts
-
write
-
write
protected static IRubyObject write(ThreadContext context, IRubyObject maybeIO, ByteList byteList, IRubyObject sep) -
write
-
write
public static IRubyObject write(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1) -
writev
-
writev
-
writev
-
writev
public static IRubyObject writev(ThreadContext context, IRubyObject io, IRubyObject arg0, IRubyObject arg1) -
writev
public static IRubyObject writev(ThreadContext context, IRubyObject io, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
inspect
Description copied from class:RubyBasicObject
Returns a string containing a human-readable representation of obj. If not overridden, uses theto_s
method to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"- Specified by:
inspect
in interfaceIRubyObject
- Overrides:
inspect
in classRubyBasicObject
-
readline
Read a line. -
readline
-
readline
-
readline
public IRubyObject readline(ThreadContext context, IRubyObject separator, IRubyObject limit, IRubyObject opts) -
getc
Deprecated. -
readchar
Read a char. On EOF throw EOFError. -
getbyte
Read a byte. On EOF returns nil. -
getByte
-
readbyte
-
getc
-
ungetbyte
-
ungetc
-
read_nonblock
-
read_nonblock
-
read_nonblock
public IRubyObject read_nonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
doReadNonblock
-
doReadNonblock
public IRubyObject doReadNonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, boolean exception) -
doReadNonblock
public IRubyObject doReadNonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, boolean exception) -
doReadNonblock
-
readpartial
-
readpartial
-
sysread
-
sysread
-
read
Deprecated. -
read
-
read
Read all available bytes. Equivalent to io_read with no arguments.- Parameters:
context
- the current context- Returns:
- the output buffer viewing the actual range of bytes read
-
read
Read length bytes. Equivalent to io_read with a length argument.- Parameters:
context
- the current contextlength
- a numeric value of the count of bytes to read- Returns:
- the output buffer viewing the actual range of bytes read
-
read
Read into the given buffer (or create a new one) reading length bytes. Equivalent to io_read.- Parameters:
context
- the current contextlength
- a numeric value of the count of bytes to readmaybeStr
- a RubyString buffer or a nil to indicate a new buffer should be created- Returns:
- the output buffer viewing the actual range of bytes read
-
checkLength
-
read
Read into the given buffer starting from start and reading len bytes. Equivalent to io_read with target byte[] buffer already in hand.- Parameters:
context
- the current contextbuffer
- the target bufferstart
- start offset in target bufferlen
- count of bytes to read- Returns:
- the number of bytes actually read or -1 for EOF
-
doRead
protected static int doRead(ThreadContext context, OpenFile fptr, byte[] buffer, int start, int len) -
readchar
Deprecated. -
stat
-
each_byteInternal
Invoke a block for each byte.
MRI: rb_io_each_byte -
each_byte
-
bytes
Deprecated. -
each_charInternal
-
each_char
-
chars
Deprecated. -
codepoints
Deprecated. -
each_codepoint
-
each
-
each
-
each
-
each
public IRubyObject each(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) -
each
-
each_line
-
each_line
-
each_line
public IRubyObject each_line(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) -
each_line
public IRubyObject each_line(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) -
each_line
-
lines
Deprecated. -
readlines
-
readlines
-
readlines
-
readlines
public RubyArray readlines(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
readlines
-
to_io
-
toString
Description copied from class:RubyObject
The default toString method is just a wrapper that calls the Ruby "to_s" method.- Overrides:
toString
in classRubyObject
- Returns:
- string representation
-
foreach
public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
convertToIO
-
select
-
wait_readable
-
wait_writable
waits until input available or timed out and returns self, or nil when EOF reached. -
wait
-
advise
-
failIfDirectory
-
ioOpen
public static IRubyObject ioOpen(ThreadContext context, IRubyObject recv, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) -
binread
binread is just like read, except it doesn't take options and it forces mode to be "rb:ASCII-8BIT"- Parameters:
context
- the current ThreadContextrecv
- the target of the call (IO or a subclass)args
- arguments; path [, length [, offset]]- Returns:
- the binary contents of the given file, at specified length and offset
-
read
public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) -
read
-
binwrite
-
write
-
ioStaticWrite
public static IRubyObject ioStaticWrite(ThreadContext context, IRubyObject recv, IRubyObject[] argv, boolean binary) -
readlines
public static IRubyObject readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) -
popen
public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
pipe
-
pipe
-
pipe
public static IRubyObject pipe(ThreadContext context, IRubyObject klass, IRubyObject arg0, Block block) -
pipe
public static IRubyObject pipe(ThreadContext context, IRubyObject klass, IRubyObject arg0, IRubyObject arg1, Block block) -
pipe
public static IRubyObject pipe(ThreadContext context, IRubyObject klass, IRubyObject v1, IRubyObject v2, IRubyObject opt, Block block) -
ensureYieldClosePipes
public static IRubyObject ensureYieldClosePipes(ThreadContext context, IRubyObject obj, RubyIO r, RubyIO w, Block block) -
copy_stream
public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) -
copy_stream
public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
copy_stream
-
tryConvert
-
pread
-
pread
public IRubyObject pread(ThreadContext context, IRubyObject _length, IRubyObject _from, IRubyObject str) -
pwrite
-
wait_readable
-
wait_writable
waits until input available or timed out and returns self, or nil when EOF reached. -
wait
-
path
-
getPath
-
setPath
-
addBlockingThread
Add a thread to the list of blocking threads for this IO.- Parameters:
thread
- A thread blocking on this IO
-
removeBlockingThread
Remove a thread from the list of blocking threads for this IO.- Parameters:
thread
- A thread blocking on this IO
-
updateIOOptionsFromOptions
protected IOOptions updateIOOptionsFromOptions(ThreadContext context, RubyHash options, IOOptions ioOptions) See http://ruby-doc.org/core-1.9.3/IO.html#method-c-new for the format of modes in options -
checkExecOptions
Deprecated. -
checkSpawnOptions
Deprecated. -
checkPopenOptions
Deprecated. -
obliterateProcess
Try for around 1s to destroy the child process. This is to work around issues on some JVMs where if you try to destroy the process too quickly it may not be ready and may ignore the destroy. A subsequent waitFor will then hang. This version tries to destroy and call exitValue repeatedly for up to 1000 calls with 1ms delay between iterations, with the intent that the target process ought to be "ready to die" fairly quickly and we don't get stuck in a blocking waitFor call.- Parameters:
process
- The process to obliterate
-
newModeFlags
-
newModeFlags
-
newModeFlags
-
newIOOptions
-
newIOOptions
-
newIOOptions
-
newIOOptions
-
newIOOptions
-
readline
Deprecated. -
setEnc2
public void setEnc2(org.jcodings.Encoding enc2) - Specified by:
setEnc2
in interfaceIOEncodable
-
setEnc
public void setEnc(org.jcodings.Encoding enc) - Specified by:
setEnc
in interfaceIOEncodable
-
setEcflags
public void setEcflags(int ecflags) - Specified by:
setEcflags
in interfaceIOEncodable
-
getEcflags
public int getEcflags()- Specified by:
getEcflags
in interfaceIOEncodable
-
setEcopts
- Specified by:
setEcopts
in interfaceIOEncodable
-
getEcopts
- Specified by:
getEcopts
in interfaceIOEncodable
-
setBOM
public void setBOM(boolean bom) - Specified by:
setBOM
in interfaceIOEncodable
-
getBOM
public boolean getBOM()- Specified by:
getBOM
in interfaceIOEncodable
-
toJava
Description copied from interface:IRubyObject
Convert the object to the specified Java class, if possible.- Specified by:
toJava
in interfaceIRubyObject
- Overrides:
toJava
in classRubyBasicObject
- Type Parameters:
T
- type- Parameters:
target
- The target type to which the object should be converted.- Returns:
- java type
- See Also:
-
setAscii8bitBinmode
-
MakeOpenFile
-
getline
Deprecated. -
getline
Deprecated. -
getline
Deprecated. -
getline
Deprecated. -
getIOModes
Deprecated. -
getIOModesIntFromString
Deprecated. -
writeStatic
@Deprecated public static IRubyObject writeStatic(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block unusedBlock) Deprecated. -
popen3
@Deprecated public static IRubyObject popen3(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Deprecated. -
popen4
@Deprecated public static IRubyObject popen4(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Deprecated. -
popenSpecial
@Deprecated public static org.jruby.RubyIO.POpenTuple popenSpecial(ThreadContext context, IRubyObject[] args) Deprecated. -
doWriteNonblock
@Deprecated public IRubyObject doWriteNonblock(ThreadContext context, IRubyObject[] argv, boolean useException) Deprecated. -
select_static
@Deprecated public static IRubyObject select_static(ThreadContext context, Ruby runtime, IRubyObject[] args) Deprecated. -
checkExecEnv
Deprecated. -
ioOpen
@Deprecated public static IRubyObject ioOpen(ThreadContext context, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) Deprecated. -
write_nonblock
Deprecated. -
read_nonblock
Deprecated. -
readpartial
Deprecated. -
sysread
Deprecated. -
pipe
@Deprecated public static IRubyObject pipe(ThreadContext context, IRubyObject klass, IRubyObject[] argv, Block block) Deprecated.
-
binmode(ThreadContext)
instead.