Package org.jruby.util.io
Class OpenFile
java.lang.Object
org.jruby.util.io.OpenFile
- All Implemented Interfaces:
Finalizable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intprotected Set<RubyThread> static final intfinal OpenFile.Bufferstatic final intstatic final intstatic final intstatic final intfinal RubyIOstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final OpenFile.FinalizerDeprecated.final PosixShimstatic final RubyThread.ReadWrite<ChannelFD> static final intstatic final RubyThread.ReadWrite<ChannelFD> final OpenFile.Bufferstatic final intorg.jcodings.transcode.EConvstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intfinal OpenFile.Bufferstatic final intorg.jcodings.transcode.EConvorg.jcodings.Encodingbooleanintstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlockingThread(RubyThread thread) Add a thread to the list of blocking threads for this IO.intappendline(ThreadContext context, int delim, ByteList[] strp, int[] lp, org.jcodings.Encoding enc) voidascii8bitBinmode(Ruby runtime) longbinwrite(ThreadContext context, byte[] ptrBytes, int ptr, int len, boolean nosync) Deprecated.intbinwriteInt(ThreadContext context, byte[] ptrBytes, int ptr, int len, boolean nosync) channel()voidcheckByteReadable(ThreadContext context) voidcheckCharReadable(ThreadContext context) voidvoidcheckReadable(ThreadContext context) voidcheckReopenSeek(ThreadContext context, Ruby runtime, long pos) voidcheckTTY()voidcheckWritable(ThreadContext context) voidvoidvoidvoidvoidstatic intcloexecDup2(PosixShim posix, ChannelFD oldfd, ChannelFD newfd) doWriteconv(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding) doWriteconv(ThreadContext context, RubyString str) jnr.constants.platform.Errnoerrno()voiderrno(jnr.constants.platform.Errno newErrno) fd()static voidfdFixCloexec(PosixShim posix, int fd) intfillbuf(ThreadContext context) voidfinalize()voidfinalize(ThreadContext context, boolean noraise) voidfinalizeFlush(ThreadContext context, boolean noraise) intintintfread(ThreadContext context, byte[] buffer, int offset, int size) intfwrite(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) longfwrite(ThreadContext context, RubyString str, boolean nosync) getc(ThreadContext context, org.jcodings.Encoding enc) protected org.jcodings.EncodinggetCommonEncodingForWriteConv(ThreadContext context, org.jcodings.Encoding strEncoding) intstatic intgetFModeFromString(String modesString) Deprecated.getlineFast(ThreadContext context, org.jcodings.Encoding enc, RubyIO io, boolean chomp) intintgetMode()getModeAsString(Ruby runtime) Deprecated.getModeAsString(ThreadContext context) static intgetModeFlagsAsIntFrom(int fmode) getPath()longgetPid()static StringgetStringFromMode(int mode) voidincrementLineno(Ruby runtime) Deprecated.voidincrementLineno(Ruby runtime, RubyIO io) org.jcodings.EncodinginputEncoding(Ruby runtime) voidinterruptBlockingThreads(ThreadContext context) Fire an IOError in all threads blocking on this IO objectintio_fflush(ThreadContext context) intstatic intioFmodeOflags(int fmode) static intioModestrFmode(Ruby runtime, String modestr) Deprecated.static intioModestrFmode(ThreadContext context, String modestr) static intioModestrOflags(Ruby runtime, String modestr) Deprecated.static intioModestrOflags(ThreadContext context, String modestr) static StringioOflagsModestr(Ruby runtime, int oflags) Deprecated.static StringioOflagsModestr(ThreadContext context, int oflags) booleanbooleanbooleanbooleanbooleanisBOM()booleanisDuplex()booleanisOpen()booleanbooleanbooleanisStdio()booleanisSync()booleanbooleanbooleanbooleanlock()booleanvoidmakeReadConversion(ThreadContext context) voidmakeReadConversion(ThreadContext context, int size) voidmakeWriteConversion(ThreadContext context) intmoreChar(ThreadContext context) booleanvoidbooleanbooleanbooleanneedsWriteConversion(ThreadContext context) static intpreadInternal(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int from, int length) static intpwriteInternal(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int from, int length) static intrbW32WriteConsole(byte[] bytes, int start, int length, org.jcodings.Encoding encoding) static longrbW32WriteConsole(RubyString buffer) booleanintintbyte[]intvoidREAD_CHECK(ThreadContext context) booleanbooleanintintbyte[]intreadAll(ThreadContext context, int siz, IRubyObject str) intreadBufferedData(byte[] ptrBytes, int ptr, int len) org.jcodings.EncodingreadEncoding(Ruby runtime) static intreadInternal(ThreadContext context, OpenFile fptr, ChannelFD fd, byte[] bufBytes, int buf, int count) static intreadInternal(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int buf, int count) intbooleanready(Ruby runtime, RubyThread thread, int ops, long timeout) Wait until the channel is available for the given operations or the timeout expires.booleanreadyNow(ThreadContext context) Likeready(org.jruby.Ruby, org.jruby.RubyThread, int, long)but returns a result immediately.intvoidremoveBlockingThread(RubyThread thread) Remove a thread from the list of blocking threads for this IO.longseek(ThreadContext context, long offset, int whence) voidvoidsetAutoclose(boolean autoclose) voidvoidvoidsetBlocking(Ruby runtime, boolean blocking) voidsetBOM(boolean bom) voidsetChannel(Channel fd) voidvoidsetFinalizer(OpenFile.Finalizer finalizer) voidsetLineNumber(int lineNumber) voidsetMode(int modes) voidsetNonblock(Ruby runtime) voidvoidsetPid(long pid) voidsetProcess(Process process) voidsetSync(boolean sync) voidshiftCbuf(int len, RubyString str) shiftCbuf(ThreadContext context, int len, IRubyObject strp) booleanswallow(ThreadContext context, int term) longtell(ThreadContext context) intthreadFlock(ThreadContext context, int lockMode) voidungetbyte(ThreadContext context, IRubyObject str) voidunlock()voidunread(ThreadContext context) voidwaitForBlockingThreads(ThreadContext context) Wait until all blocking threads have exited their blocking area.booleanwaitReadable(ThreadContext context) booleanwaitReadable(ThreadContext context, long timeout) booleanwaitWritable(ThreadContext context) booleanwaitWritable(ThreadContext context, long timeout) static intwriteInternal(ThreadContext context, OpenFile fptr, byte[] bufBytes, int buf, int count) static intwriteInternal(ThreadContext context, OpenFile fptr, ByteBuffer bufBytes, int buf, int count)
-
Field Details
-
READABLE
public static final int READABLE- See Also:
-
WRITABLE
public static final int WRITABLE- See Also:
-
READWRITE
public static final int READWRITE- See Also:
-
BINMODE
public static final int BINMODE- See Also:
-
SYNC
public static final int SYNC- See Also:
-
TTY
public static final int TTY- See Also:
-
DUPLEX
public static final int DUPLEX- See Also:
-
APPEND
public static final int APPEND- See Also:
-
CREATE
public static final int CREATE- See Also:
-
WSPLIT
public static final int WSPLIT- See Also:
-
EXCLUSIVE
public static final int EXCLUSIVE- See Also:
-
TRUNC
public static final int TRUNC- See Also:
-
TEXTMODE
public static final int TEXTMODE- See Also:
-
SETENC_BY_BOM
public static final int SETENC_BY_BOM- See Also:
-
TMPFILE
public static final int TMPFILE- See Also:
-
PREP
public static final int PREP- See Also:
-
SYNCWRITE
public static final int SYNCWRITE- See Also:
-
PIPE_BUF
public static final int PIPE_BUF- See Also:
-
BUFSIZ
public static final int BUFSIZ- See Also:
-
stdio_file
-
currentLock
-
encs
-
readconv
public org.jcodings.transcode.EConv readconv -
writeconv
public org.jcodings.transcode.EConv writeconv -
writeconvAsciicompat
public org.jcodings.Encoding writeconvAsciicompat -
writeconvPreEcflags
public int writeconvPreEcflags -
writeconvPreEcopts
-
writeconvInitialized
public boolean writeconvInitialized -
write_lock
-
wbuf
-
rbuf
-
cbuf
-
io
-
tiedIOForWriting
-
posix
-
blockingThreads
-
PIPE_FINALIZE
Deprecated. -
MORE_CHAR_SUSPENDED
public static final int MORE_CHAR_SUSPENDED- See Also:
-
MORE_CHAR_FINISHED
public static final int MORE_CHAR_FINISHED- See Also:
-
EOF
public static final int EOF- See Also:
-
IO_RBUF_CAPA_MIN
public static final int IO_RBUF_CAPA_MIN- See Also:
-
IO_CBUF_CAPA_MIN
public static final int IO_CBUF_CAPA_MIN- See Also:
-
IO_WBUF_CAPA_MIN
public static final int IO_WBUF_CAPA_MIN- See Also:
-
PREAD_TASK
-
PWRITE_TASK
-
-
Constructor Details
-
OpenFile
-
-
Method Details
-
ascii8bitBinmode
-
checkReopenSeek
-
clearStdio
public void clearStdio() -
PREP_STDIO_NAME
-
READ_DATA_PENDING
public boolean READ_DATA_PENDING() -
READ_DATA_PENDING_COUNT
public int READ_DATA_PENDING_COUNT() -
READ_DATA_PENDING_PTR
public byte[] READ_DATA_PENDING_PTR() -
READ_DATA_PENDING_OFF
public int READ_DATA_PENDING_OFF() -
READ_DATA_PENDING_START
public int READ_DATA_PENDING_START() -
READ_DATA_BUFFERED
public boolean READ_DATA_BUFFERED() -
READ_CHAR_PENDING
public boolean READ_CHAR_PENDING() -
READ_CHAR_PENDING_COUNT
public int READ_CHAR_PENDING_COUNT() -
READ_CHAR_PENDING_PTR
public byte[] READ_CHAR_PENDING_PTR() -
READ_CHAR_PENDING_OFF
public int READ_CHAR_PENDING_OFF() -
READ_CHAR_PENDING_START
public int READ_CHAR_PENDING_START() -
READ_CHECK
-
IS_PREP_STDIO
public boolean IS_PREP_STDIO() -
setFD
-
setChannel
-
getMode
public int getMode() -
getModeAsString
Deprecated. -
getModeAsString
-
getModeFlagsAsIntFrom
public static int getModeFlagsAsIntFrom(int fmode) -
ioOflagsModestr
Deprecated. -
ioOflagsModestr
-
ioModestrOflags
Deprecated. -
ioModestrOflags
-
ioFmodeOflags
public static int ioFmodeOflags(int fmode) -
ioModestrFmode
Deprecated. -
ioModestrFmode
-
getStringFromMode
-
checkCharReadable
-
checkByteReadable
-
checkReadable
-
io_fflush
-
waitWritable
-
waitWritable
-
waitReadable
-
waitReadable
-
ready
Wait until the channel is available for the given operations or the timeout expires.- Parameters:
runtime-ops-timeout-- Returns:
- See Also:
-
readyNow
Likeready(org.jruby.Ruby, org.jruby.RubyThread, int, long)but returns a result immediately.- Parameters:
context-- Returns:
-
flushBuffer
public int flushBuffer() -
flushBufferAsync2
public int flushBufferAsync2() -
seek
-
checkWritable
-
checkClosed
public void checkClosed() -
isBinmode
public boolean isBinmode() -
isTextMode
public boolean isTextMode() -
setTextMode
public void setTextMode() -
clearTextMode
public void clearTextMode() -
setBinmode
public void setBinmode() -
isOpen
public boolean isOpen() -
isReadable
public boolean isReadable() -
isWritable
public boolean isWritable() -
isDuplex
public boolean isDuplex() -
isReadBuffered
public boolean isReadBuffered() -
isWriteBuffered
public boolean isWriteBuffered() -
setSync
public void setSync(boolean sync) -
isSync
public boolean isSync() -
setMode
public void setMode(int modes) -
getProcess
-
setProcess
-
getPid
public long getPid() -
setPid
public void setPid(long pid) -
getLineNumber
public int getLineNumber() -
setLineNumber
public void setLineNumber(int lineNumber) -
getPath
-
setPath
-
isAutoclose
public boolean isAutoclose() -
setAutoclose
public void setAutoclose(boolean autoclose) -
getFinalizer
-
setFinalizer
-
cleanup
-
finalize
public void finalize()- Specified by:
finalizein interfaceFinalizable- Overrides:
finalizein classObject
-
finalize
-
finalizeFlush
-
needsReadConversion
public boolean needsReadConversion() -
needsWriteConversion
-
makeReadConversion
-
makeReadConversion
-
makeWriteConversion
-
clearReadConversion
public void clearReadConversion() -
clearCodeConversion
public void clearCodeConversion() -
IO_RBUF_CAPA_FOR
public int IO_RBUF_CAPA_FOR() -
appendline
public int appendline(ThreadContext context, int delim, ByteList[] strp, int[] lp, org.jcodings.Encoding enc) -
NEED_NEWLINE_DECORATOR_ON_READ_CHECK
public void NEED_NEWLINE_DECORATOR_ON_READ_CHECK() -
NEED_NEWLINE_DECORATOR_ON_READ
public boolean NEED_NEWLINE_DECORATOR_ON_READ() -
NEED_NEWLINE_DECORATOR_ON_WRITE
public boolean NEED_NEWLINE_DECORATOR_ON_WRITE() -
moreChar
-
readBufferedData
public int readBufferedData(byte[] ptrBytes, int ptr, int len) -
fillbuf
-
readInternal
public static int readInternal(ThreadContext context, OpenFile fptr, ChannelFD fd, byte[] bufBytes, int buf, int count) -
readInternal
public static int readInternal(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int buf, int count) -
preadInternal
public static int preadInternal(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int from, int length) -
pwriteInternal
public static int pwriteInternal(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int from, int length) -
readEncoding
-
inputEncoding
-
swallow
-
shiftCbuf
-
shiftCbuf
-
getlineFast
public IRubyObject getlineFast(ThreadContext context, org.jcodings.Encoding enc, RubyIO io, boolean chomp) -
incrementLineno
-
incrementLineno
Deprecated. -
readAll
-
fread
-
ungetbyte
-
getc
-
tell
-
unread
-
fwrite
-
fwrite
public int fwrite(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) -
rbW32WriteConsole
-
rbW32WriteConsole
public static int rbW32WriteConsole(byte[] bytes, int start, int length, org.jcodings.Encoding encoding) -
doWriteconv
-
getCommonEncodingForWriteConv
protected org.jcodings.Encoding getCommonEncodingForWriteConv(ThreadContext context, org.jcodings.Encoding strEncoding) -
doWriteconv
public ByteList doWriteconv(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding) -
binwriteInt
-
writeInternal
public static int writeInternal(ThreadContext context, OpenFile fptr, byte[] bufBytes, int buf, int count) -
writeInternal
public static int writeInternal(ThreadContext context, OpenFile fptr, ByteBuffer bufBytes, int buf, int count) -
fd
-
channel
-
readChannel
-
writeChannel
-
seekChannel
-
selectChannel
-
fileChannel
-
socketChannel
-
setNonblock
-
setBlock
-
setBlocking
-
isBlocking
public boolean isBlocking() -
checkTTY
public void checkTTY() -
isBOM
public boolean isBOM() -
setBOM
public void setBOM(boolean bom) -
isStdio
public boolean isStdio() -
readPending
public int readPending() -
getFModeFromString
Deprecated.- Throws:
InvalidValueException
-
getFileno
public int getFileno() -
threadFlock
-
errno
public jnr.constants.platform.Errno errno() -
errno
public void errno(jnr.constants.platform.Errno newErrno) -
cloexecDup2
-
fdFixCloexec
-
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
-
interruptBlockingThreads
Fire an IOError in all threads blocking on this IO object -
waitForBlockingThreads
Wait until all blocking threads have exited their blocking area. Use in combination with interruptBlockingThreads to ensure every blocking thread has moved on before proceding to manipulate the IO. -
SET_BINARY_MODE
public void SET_BINARY_MODE() -
remainSize
public int remainSize() -
lock
public boolean lock() -
unlock
public void unlock() -
lockedByMe
public boolean lockedByMe() -
binwrite
@Deprecated public long binwrite(ThreadContext context, byte[] ptrBytes, int ptr, int len, boolean nosync) Deprecated.
-