public class RubyIO extends RubyObject implements IOEncodable
RubyObject.Data
RubyBasicObject.Finalizer
IOEncodable.ConvConfig
Modifier and Type | Field and Description |
---|---|
static String |
CLOSED_STREAM_MSG |
protected OpenFile |
openFile |
static org.jruby.util.ByteList |
PARAGRAPH_DELIMETER |
static org.jruby.util.ByteList |
PARAGRAPH_SEPARATOR |
protected boolean |
popenSpecial
If the stream is being used for popen, we don't want to destroy the process
when we close the stream.
|
FIELD_ALLOCATED_CLASSES, FIELD_ALLOCATOR_SET, FIELD_ALLOCATORS, IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, OBJECT_VAR0_ALLOCATOR, OBJECT_VAR1_ALLOCATOR, OBJECT_VAR2_ALLOCATOR, OBJECT_VAR3_ALLOCATOR, OBJECT_VAR4_ALLOCATOR, OBJECT_VAR5_ALLOCATOR, OBJECT_VAR6_ALLOCATOR, OBJECT_VAR7_ALLOCATOR, OBJECT_VAR8_ALLOCATOR, OBJECT_VAR9_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
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, UNTRUST_F, 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
NULL_ARRAY
Constructor and Description |
---|
RubyIO(Ruby runtime,
Channel channel) |
RubyIO(Ruby runtime,
InputStream inputStream) |
RubyIO(Ruby runtime,
OutputStream outputStream) |
RubyIO(Ruby runtime,
OutputStream outputStream,
boolean autoclose) |
RubyIO(Ruby runtime,
RubyClass type) |
RubyIO(Ruby runtime,
RubyClass klass,
Channel channel) |
RubyIO(Ruby runtime,
RubyClass cls,
ShellLauncher.POpenProcess process,
RubyHash options,
IOOptions ioOptions)
Deprecated.
|
RubyIO(Ruby runtime,
ShellLauncher.POpenProcess process,
IOOptions ioOptions) |
RubyIO(Ruby runtime,
STDIO stdio)
Deprecated.
|
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, dig, eqlInternal, equalInternal, equals, hashCode, inspect, op_eqq, puts, specificEval
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize, initialize19, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, toJava, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
public static final org.jruby.util.ByteList PARAGRAPH_DELIMETER
public static final org.jruby.util.ByteList PARAGRAPH_SEPARATOR
public static final String CLOSED_STREAM_MSG
protected OpenFile openFile
protected boolean popenSpecial
public RubyIO(Ruby runtime, OutputStream outputStream)
public RubyIO(Ruby runtime, OutputStream outputStream, boolean autoclose)
public RubyIO(Ruby runtime, InputStream inputStream)
public RubyIO(Ruby runtime, ShellLauncher.POpenProcess process, IOOptions ioOptions)
@Deprecated public RubyIO(Ruby runtime, STDIO stdio)
@Deprecated public RubyIO(Ruby runtime, RubyClass cls, ShellLauncher.POpenProcess process, RubyHash options, IOOptions ioOptions)
public static RubyIO prepStdio(Ruby runtime, InputStream f, Channel c, int fmode, RubyClass klass, String path)
public static RubyIO prepStdio(Ruby runtime, OutputStream f, Channel c, int fmode, RubyClass klass, String path)
public OpenFile getOpenFile()
public OpenFile getOpenFileChecked()
public OpenFile getOpenFileInitialized()
public ClassIndex getNativeClassIndex()
RubyObject
getNativeClassIndex
in interface CoreObjectType
getNativeClassIndex
in class RubyObject
ClassIndex
public OutputStream getOutStream()
public InputStream getInStream()
public Channel getChannel()
protected RubyIO reopenIO(ThreadContext context, RubyIO nfile)
public IRubyObject reopen(ThreadContext context, IRubyObject[] args)
public IRubyObject getline(ThreadContext context, IRubyObject separator)
public IRubyObject getline(ThreadContext context, IRubyObject separator, long limit)
public org.jcodings.Encoding getEnc()
getEnc
in interface IOEncodable
public org.jcodings.Encoding getReadEncoding()
public org.jcodings.Encoding getEnc2()
getEnc2
in interface IOEncodable
public org.jcodings.Encoding getInputEncoding()
public static boolean restartSystemCall(Exception e)
public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject for_fd(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public IRubyObject initialize(ThreadContext context, IRubyObject fileNumber, Block unused)
public IRubyObject initialize(ThreadContext context, IRubyObject fileNumber, IRubyObject second, Block unused)
public IRubyObject initialize(ThreadContext context, IRubyObject fileNumber, IRubyObject modeValue, IRubyObject options, Block unused)
protected IOOptions parseIOOptions(IRubyObject arg)
public IRubyObject external_encoding(ThreadContext context)
public IRubyObject internal_encoding(ThreadContext context)
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingObj)
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding)
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding, IRubyObject options)
public void setEncoding(ThreadContext context, IRubyObject v1, IRubyObject v2, IRubyObject opt)
public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject ensureYieldClose(ThreadContext context, IRubyObject port, Block block)
public static IRubyObject sysopen(IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject sysopen19(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block block)
public boolean isAutoclose()
public void setAutoclose(boolean autoclose)
public IRubyObject autoclose(ThreadContext context)
public IRubyObject autoclose_set(ThreadContext context, IRubyObject autoclose)
public IRubyObject binmode()
public IRubyObject op_binmode(ThreadContext context)
public IRubyObject syswrite(ThreadContext context, IRubyObject str)
public IRubyObject write_nonblock(ThreadContext context, IRubyObject[] argv)
public RubyIO GetWriteIO()
public IRubyObject write(ThreadContext context, IRubyObject str)
public IRubyObject write(ThreadContext context, IRubyObject str, boolean nosync)
public IRubyObject op_append(ThreadContext context, IRubyObject anObject)
public RubyFixnum fileno(ThreadContext context)
public RubyFixnum lineno(ThreadContext context)
public RubyFixnum lineno_set(ThreadContext context, IRubyObject newLineNumber)
newLineNumber
- The new line number.public RubyBoolean sync(ThreadContext context)
public IRubyObject pid(ThreadContext context)
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.
public RubyFixnum pos(ThreadContext context)
public RubyFixnum pos_set(ThreadContext context, IRubyObject offset)
public IRubyObject print(ThreadContext context, IRubyObject[] args)
public static IRubyObject print(ThreadContext context, IRubyObject out, IRubyObject[] args)
public IRubyObject printf(ThreadContext context, IRubyObject[] args)
public IRubyObject putc(ThreadContext context, IRubyObject ch)
public static IRubyObject putc(ThreadContext context, IRubyObject maybeIO, IRubyObject object)
public RubyFixnum seek(ThreadContext context, IRubyObject[] args)
public RubyFixnum seek(ThreadContext context, IRubyObject arg0)
public RubyFixnum seek(ThreadContext context, IRubyObject arg0, IRubyObject arg1)
public RubyFixnum sysseek(ThreadContext context, IRubyObject[] args)
public RubyFixnum rewind(ThreadContext context)
public RubyFixnum fsync(ThreadContext context)
public IRubyObject sync_set(IRubyObject sync)
sync
- The new sync mode.public void setSync(boolean sync)
public boolean getSync()
public RubyBoolean eof_p(ThreadContext context)
public RubyBoolean tty_p(ThreadContext context)
public IRubyObject initialize_copy(IRubyObject _io)
RubyBasicObject
initialize_copy
in class RubyBasicObject
public RubyBoolean closed_p(ThreadContext context)
public boolean isClosed()
public IRubyObject close()
Closes all open resources for the IO. It also removes it from our magical all open file descriptor pool.
protected static IRubyObject ioClose(Ruby runtime, IRubyObject io)
protected IRubyObject rbIoClose(Ruby runtime)
public IRubyObject close_write(ThreadContext context)
public IRubyObject close_read(ThreadContext context)
public IRubyObject close_on_exec_set(ThreadContext context, IRubyObject arg)
public IRubyObject close_on_exec_p(ThreadContext context)
public RubyIO flush(ThreadContext context)
protected RubyIO flushRaw(ThreadContext context, boolean sync)
public IRubyObject gets(ThreadContext context)
public IRubyObject gets(ThreadContext context, IRubyObject arg)
public IRubyObject gets(ThreadContext context, IRubyObject rs, IRubyObject limit_arg)
public boolean getBlocking()
public void setBlocking(boolean blocking)
public IRubyObject fcntl(ThreadContext context, IRubyObject cmd)
public IRubyObject fcntl(ThreadContext context, IRubyObject cmd, IRubyObject arg)
public IRubyObject ioctl(ThreadContext context, IRubyObject[] args)
public IRubyObject ctl(Ruby runtime, IRubyObject cmd, IRubyObject arg)
public IRubyObject puts(ThreadContext context)
public IRubyObject puts(ThreadContext context, IRubyObject arg0)
public IRubyObject puts(ThreadContext context, IRubyObject arg0, IRubyObject arg1)
public IRubyObject puts(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2)
public IRubyObject puts(ThreadContext context, IRubyObject[] args)
public static IRubyObject puts0(ThreadContext context, IRubyObject maybeIO)
public static IRubyObject puts1(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0)
public static IRubyObject puts2(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1)
public static IRubyObject puts3(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2)
public static IRubyObject puts(ThreadContext context, IRubyObject maybeIO, IRubyObject... args)
protected IRubyObject write(ThreadContext context, org.jruby.util.ByteList byteList)
protected static IRubyObject write(ThreadContext context, IRubyObject maybeIO, org.jruby.util.ByteList byteList)
public static IRubyObject write(ThreadContext context, IRubyObject maybeIO, IRubyObject str)
public IRubyObject inspect()
RubyBasicObject
to_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"inspect
in interface IRubyObject
inspect
in class RubyBasicObject
public IRubyObject readline(ThreadContext context)
public IRubyObject readline(ThreadContext context, IRubyObject separator)
public IRubyObject getc()
public IRubyObject readchar(ThreadContext context)
public IRubyObject getbyte(ThreadContext context)
public int getByte(ThreadContext context)
public IRubyObject readbyte(ThreadContext context)
public IRubyObject getc19(ThreadContext context)
public IRubyObject ungetbyte(ThreadContext context, IRubyObject b)
public IRubyObject ungetc(ThreadContext context, IRubyObject c)
public IRubyObject read_nonblock(ThreadContext context, IRubyObject[] args)
public IRubyObject doReadNonblock(ThreadContext context, IRubyObject[] args, boolean useException)
public IRubyObject readpartial(ThreadContext context, IRubyObject[] args)
public IRubyObject sysread(ThreadContext context, IRubyObject[] args)
public IRubyObject read(IRubyObject[] args)
public IRubyObject read(ThreadContext context)
public IRubyObject read(ThreadContext context, IRubyObject arg0)
public IRubyObject read(ThreadContext context, IRubyObject length, IRubyObject str)
public IRubyObject readchar()
public IRubyObject stat(ThreadContext context)
public IRubyObject each_byteInternal(ThreadContext context, Block block)
Invoke a block for each byte.
MRI: rb_io_each_bytepublic IRubyObject each_byte(ThreadContext context, Block block)
public IRubyObject bytes(ThreadContext context, Block block)
public IRubyObject each_charInternal(ThreadContext context, Block block)
public IRubyObject each_char(ThreadContext context, Block block)
public IRubyObject chars(ThreadContext context, Block block)
public IRubyObject codepoints(ThreadContext context, Block block)
public IRubyObject each_codepoint(ThreadContext context, Block block)
public IRubyObject each(ThreadContext context, IRubyObject[] args, Block block)
public IRubyObject each_line(ThreadContext context, IRubyObject[] args, Block block)
public IRubyObject lines(ThreadContext context, Block block)
public RubyArray readlines(ThreadContext context, IRubyObject[] args)
public RubyIO to_io()
public String toString()
RubyObject
toString
in class RubyObject
public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static RubyIO convertToIO(ThreadContext context, IRubyObject obj)
public static IRubyObject select(ThreadContext context, IRubyObject recv, IRubyObject[] argv)
public IRubyObject advise(ThreadContext context, IRubyObject[] argv)
public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public static void failIfDirectory(Ruby runtime, RubyString pathStr)
public static IRubyObject ioOpen(ThreadContext context, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt)
public static IRubyObject binread(ThreadContext context, IRubyObject recv, IRubyObject[] args)
context
- the current ThreadContextrecv
- the target of the call (IO or a subclass)args
- arguments; path [, length [, offset]]public static IRubyObject read19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock)
public static IRubyObject binwrite(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public static IRubyObject write(ThreadContext context, IRubyObject recv, IRubyObject[] argv)
public static IRubyObject ioStaticWrite(ThreadContext context, IRubyObject recv, IRubyObject[] argv, boolean binary)
public static IRubyObject readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock)
public static IRubyObject readlines19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock)
public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject pipe(ThreadContext context, IRubyObject recv)
public static IRubyObject pipe19(ThreadContext context, IRubyObject recv)
public static IRubyObject pipe19(ThreadContext context, IRubyObject recv, IRubyObject modes)
public static IRubyObject pipe19(ThreadContext context, IRubyObject klass, IRubyObject[] argv, Block block)
public static IRubyObject ensureYieldClosePipes(ThreadContext context, IRubyObject obj, RubyIO r, RubyIO w, Block block)
public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public static IRubyObject tryConvert(ThreadContext context, IRubyObject recv, IRubyObject arg)
public void addBlockingThread(RubyThread thread)
thread
- A thread blocking on this IOpublic void removeBlockingThread(RubyThread thread)
thread
- A thread blocking on this IOprotected void interruptBlockingThreads()
protected IOOptions updateIOOptionsFromOptions(ThreadContext context, RubyHash options, IOOptions ioOptions)
public static void checkExecOptions(IRubyObject options)
options
- public static void checkSpawnOptions(IRubyObject options)
options
- public static void checkPopenOptions(IRubyObject options)
options
- public static RubyArray checkExecEnv(ThreadContext context, RubyHash hash)
public static void obliterateProcess(Process process)
process
- The process to obliterate@Deprecated public IRubyObject readline(ThreadContext context, IRubyObject[] args)
public void setEnc2(org.jcodings.Encoding enc2)
setEnc2
in interface IOEncodable
public void setEnc(org.jcodings.Encoding enc)
setEnc
in interface IOEncodable
public void setEcflags(int ecflags)
setEcflags
in interface IOEncodable
public int getEcflags()
getEcflags
in interface IOEncodable
public void setEcopts(IRubyObject ecopts)
setEcopts
in interface IOEncodable
public IRubyObject getEcopts()
getEcopts
in interface IOEncodable
public void setBOM(boolean bom)
setBOM
in interface IOEncodable
public boolean getBOM()
getBOM
in interface IOEncodable
protected RubyIO setAscii8bitBinmode()
public final OpenFile MakeOpenFile()
@Deprecated public IRubyObject getline(Ruby runtime, org.jruby.util.ByteList separator)
@Deprecated public IRubyObject getline(Ruby runtime, org.jruby.util.ByteList separator, long limit)
@Deprecated public IRubyObject getline(ThreadContext context, org.jruby.util.ByteList separator)
@Deprecated public IRubyObject getline(ThreadContext context, org.jruby.util.ByteList separator, long limit)
@Deprecated public IRubyObject lines19(ThreadContext context, Block block)
@Deprecated public IRubyObject each_char19(ThreadContext context, Block block)
@Deprecated public IRubyObject chars19(ThreadContext context, Block block)
@Deprecated public RubyArray readlines19(ThreadContext context, IRubyObject[] args)
@Deprecated public static ModeFlags getIOModes(Ruby runtime, String modesString)
@Deprecated public static int getIOModesIntFromString(Ruby runtime, String modesString)
@Deprecated public static IRubyObject writeStatic(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block unusedBlock)
@Deprecated public static IRubyObject popen3(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
@Deprecated public static IRubyObject popen4(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
@Deprecated public static org.jruby.RubyIO.POpenTuple popenSpecial(ThreadContext context, IRubyObject[] args)
@Deprecated public IRubyObject doWriteNonblock(ThreadContext context, IRubyObject[] argv, boolean useException)
@Deprecated public static IRubyObject select_static(ThreadContext context, Ruby runtime, IRubyObject[] args)
Copyright © 2001-2017 JRuby. All Rights Reserved.