public class RubyIO extends RubyObject implements IOEncodable
RubyObject.Data
RubyBasicObject.Finalizer
IOEncodable.ConvConfig
Modifier and Type | Field and Description |
---|---|
protected List<RubyThread> |
blockingThreads |
protected int |
ecflags |
protected IRubyObject |
ecopts |
protected org.jcodings.Encoding |
enc
readEncoding/writeEncoding deserve a paragraph explanation.
|
protected org.jcodings.Encoding |
enc2 |
protected boolean |
hasBom |
protected OpenFile |
openFile |
protected boolean |
popenSpecial
If the stream is being used for popen, we don't want to destroy the process
when we close the stream.
|
protected Transcoder |
readconv |
protected Transcoder |
writeconv |
protected IRubyObject |
writeconvAsciicompat |
protected boolean |
writeconvInitialized |
protected int |
writeconvPreEcflags |
protected IRubyObject |
writeconvPreEcopts |
FIELD_ALLOCATED_CLASSES, 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, metaClass, NEVER, NIL_F, STAMP_OFFSET, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_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 cls,
ShellLauncher.POpenProcess process,
RubyHash options,
IOOptions ioOptions)
Deprecated.
|
RubyIO(Ruby runtime,
ShellLauncher.POpenProcess process,
IOOptions ioOptions) |
RubyIO(Ruby runtime,
STDIO stdio) |
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, hashCode, initialize, initialize, inspect, op_eqq, puts, specificEval
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, 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, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, 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, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, 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, 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, singleton_methods19, 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, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
protected Transcoder readconv
protected boolean writeconvInitialized
protected Transcoder writeconv
protected OpenFile openFile
protected List<RubyThread> blockingThreads
protected org.jcodings.Encoding enc
protected org.jcodings.Encoding enc2
protected int ecflags
protected IRubyObject ecopts
protected int writeconvPreEcflags
protected IRubyObject writeconvPreEcopts
protected IRubyObject writeconvAsciicompat
protected boolean popenSpecial
protected boolean hasBom
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, RubyClass cls, ShellLauncher.POpenProcess process, RubyHash options, IOOptions ioOptions)
public OpenFile getOpenFile()
protected OpenFile getOpenFileChecked()
public int getNativeTypeIndex()
RubyObject
getNativeTypeIndex
in interface CoreObjectType
getNativeTypeIndex
in class RubyObject
ClassIndex
public OutputStream getOutStream()
public InputStream getInStream()
public Channel getChannel()
@Deprecated public Stream getHandler() throws BadDescriptorException
BadDescriptorException
protected Stream reprocessStreamInCaseECOptsWantsCRLF(Stream fd, ModeFlags modes)
protected void reopenPath(Ruby runtime, IRubyObject[] args)
public IRubyObject reopen(ThreadContext context, IRubyObject[] args)
@Deprecated public static ModeFlags getIOModes(Ruby runtime, String modesString)
@Deprecated public static int getIOModesIntFromString(Ruby runtime, String modesString)
public IRubyObject getline(ThreadContext context, org.jruby.util.ByteList separator)
public IRubyObject getline(ThreadContext context, org.jruby.util.ByteList 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()
protected boolean swallow(int term) throws IOException, BadDescriptorException
IOException
BadDescriptorException
public static boolean restartSystemCall(Exception e)
public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public IRubyObject initialize19(ThreadContext context, IRubyObject fileNumber, Block unused)
public IRubyObject initialize19(ThreadContext context, IRubyObject fileNumber, IRubyObject second, Block unused)
public IRubyObject initialize19(ThreadContext context, IRubyObject fileNumber, IRubyObject modeValue, IRubyObject options, Block unused)
protected IOOptions parseIOOptions(IRubyObject arg)
protected IOOptions parseIOOptions19(IRubyObject arg)
public IRubyObject initialize(IRubyObject[] args, Block unusedBlock)
protected Stream fdopen(ChannelDescriptor existingDescriptor, ModeFlags modes)
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 sysopen(IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject sysopen19(ThreadContext context, IRubyObject recv, IRubyObject[] args, 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 obj)
public IRubyObject write_nonblock(ThreadContext context, IRubyObject obj)
public IRubyObject doWriteNonblock(ThreadContext context, IRubyObject obj, boolean useException)
public IRubyObject write(ThreadContext context, IRubyObject obj)
protected int fwrite(RubyString buffer)
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 newPosition)
public IRubyObject print(ThreadContext context, IRubyObject[] args)
public static IRubyObject print(ThreadContext context, IRubyObject maybeIO, IRubyObject[] args)
public static IRubyObject print19(ThreadContext context, IRubyObject maybeIO, IRubyObject[] args)
public IRubyObject printf(ThreadContext context, IRubyObject[] args)
public IRubyObject putc(ThreadContext context, IRubyObject object)
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 newSync)
newSync
- The new sync mode.public RubyBoolean eof_p(ThreadContext context)
public RubyBoolean tty_p(ThreadContext context)
public IRubyObject initialize_copy(IRubyObject original)
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 IRubyObject ioClose(Ruby runtime)
public IRubyObject close_write(ThreadContext context)
public IRubyObject close_read(ThreadContext context)
public RubyIO flush()
public IRubyObject gets(ThreadContext context)
public IRubyObject gets(ThreadContext context, IRubyObject separatorArg)
public IRubyObject gets19(ThreadContext context)
public IRubyObject gets19(ThreadContext context, IRubyObject arg)
public IRubyObject gets19(ThreadContext context, IRubyObject separator, IRubyObject limit_arg)
public boolean getBlocking()
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 readchar19(ThreadContext context)
public IRubyObject getbyte19(ThreadContext context)
public IRubyObject readbyte(ThreadContext context)
public IRubyObject getc19(ThreadContext context)
public int getcCommon()
public IRubyObject ungetc(IRubyObject number)
Pushes char represented by int back onto IOS.
number
- to push backpublic IRubyObject ungetc19(IRubyObject character)
public void ungetcCommon(int ch)
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 arg0, IRubyObject arg1)
protected static boolean emptyBufferOrEOF(org.jruby.util.ByteList buffer, OpenFile myOpenFile) throws BadDescriptorException, IOException
BadDescriptorException
IOException
protected RubyString readAll(RubyString str) throws BadDescriptorException, EOFException, IOException
protected IRubyObject readAll(ThreadContext context) throws BadDescriptorException, EOFException, IOException
protected org.jruby.util.ByteList readAllCommon(Ruby runtime) throws BadDescriptorException, EOFException, IOException
public IRubyObject readchar()
public IRubyObject stat(ThreadContext context)
public IRubyObject each_byteInternal(ThreadContext context, Block block)
Invoke a block for each byte.
public IRubyObject each_byte(ThreadContext context, Block block)
public IRubyObject bytes(ThreadContext context)
public IRubyObject lines(ThreadContext context, Block block)
public IRubyObject lines19(ThreadContext context, Block block)
public IRubyObject each_charInternal(ThreadContext context, Block block)
public IRubyObject each_charInternal19(ThreadContext context, Block block)
public IRubyObject each_char(ThreadContext context, Block block)
public IRubyObject each_char19(ThreadContext context, Block block)
public IRubyObject chars(ThreadContext context, Block block)
public IRubyObject chars19(ThreadContext context, Block block)
public IRubyObject codepoints(ThreadContext context, Block block)
public IRubyObject each_codepoint(ThreadContext context, Block block)
public RubyIO each_lineInternal(ThreadContext context, IRubyObject[] args, Block block)
Invoke a block for each line.
public IRubyObject each(ThreadContext context, IRubyObject[] args, Block block)
public IRubyObject each_line(ThreadContext context, IRubyObject[] args, Block block)
public RubyArray readlines(ThreadContext context, IRubyObject[] args)
public RubyArray readlines19(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 IRubyObject foreach19(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[] args)
public static IRubyObject select_static(ThreadContext context, Ruby runtime, IRubyObject[] args)
public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public static void failIfDirectory(Ruby runtime, RubyString pathStr)
@Deprecated public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject path, Block unusedBlock)
@Deprecated public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length)
@Deprecated public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length, IRubyObject offset)
public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path)
public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length)
public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length, IRubyObject offset)
public static IRubyObject ioOpen(ThreadContext context, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt)
public static IRubyObject checkPipeCommand(ThreadContext context, IRubyObject filenameOrCommand)
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 writeStatic(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock)
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 popen19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject popen3(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject popen3_19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject popen4(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static org.jruby.RubyIO.POpenTuple popenSpecial(ThreadContext context, IRubyObject[] args)
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 recv, IRubyObject modes, IRubyObject options)
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 final IOOptions updateIOOptionsFromOptions(ThreadContext context, RubyHash options, IOOptions ioOptions)
public org.jcodings.Encoding encodingFromBOM()
public static void checkExecOptions(IRubyObject options)
options
- public static void checkSpawnOptions(IRubyObject options)
options
- public static void checkPopenOptions(IRubyObject options)
options
- public static void obliterateProcess(Process process)
process
- The process to obliteratepublic boolean writeDataBuffered()
@Deprecated public void registerDescriptor(ChannelDescriptor descriptor, boolean isRetained)
@Deprecated public void registerDescriptor(ChannelDescriptor descriptor)
@Deprecated public void unregisterDescriptor(int aFileno)
@Deprecated public ChannelDescriptor getDescriptorByFileno(int aFileno)
@Deprecated public static int getNewFileno()
@Deprecated public IRubyObject gets(ThreadContext context, IRubyObject[] args)
@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 void setAscii8bitBinmode()
protected void 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)
Copyright © 2001-2017 JRuby. All Rights Reserved.