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 class
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
protected Set
<RubyThread> static final int
final OpenFile.Buffer
static final int
static final int
static final int
static final int
final RubyIO
static final int
static final int
static final int
static final int
static final int
static final int
static final OpenFile.Finalizer
Deprecated.final PosixShim
static final RubyThread.ReadWrite
<ChannelFD> static final int
static final RubyThread.ReadWrite
<ChannelFD> final OpenFile.Buffer
static final int
org.jcodings.transcode.EConv
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
final OpenFile.Buffer
static final int
org.jcodings.transcode.EConv
org.jcodings.Encoding
boolean
int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBlockingThread
(RubyThread thread) Add a thread to the list of blocking threads for this IO.int
appendline
(ThreadContext context, int delim, ByteList[] strp, int[] lp, org.jcodings.Encoding enc) void
ascii8bitBinmode
(Ruby runtime) long
binwrite
(ThreadContext context, byte[] ptrBytes, int ptr, int len, boolean nosync) Deprecated.int
binwriteInt
(ThreadContext context, byte[] ptrBytes, int ptr, int len, boolean nosync) channel()
void
checkByteReadable
(ThreadContext context) void
checkCharReadable
(ThreadContext context) void
void
checkReadable
(ThreadContext context) void
checkReopenSeek
(ThreadContext context, Ruby runtime, long pos) void
checkTTY()
void
checkWritable
(ThreadContext context) void
void
void
void
void
static int
cloexecDup2
(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.Errno
errno()
void
errno
(jnr.constants.platform.Errno newErrno) fd()
static void
fdFixCloexec
(PosixShim posix, int fd) int
fillbuf
(ThreadContext context) void
finalize()
void
finalize
(ThreadContext context, boolean noraise) void
finalizeFlush
(ThreadContext context, boolean noraise) int
int
int
fread
(ThreadContext context, byte[] buffer, int offset, int size) int
fwrite
(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) long
fwrite
(ThreadContext context, RubyString str, boolean nosync) getc
(ThreadContext context, org.jcodings.Encoding enc) protected org.jcodings.Encoding
getCommonEncodingForWriteConv
(ThreadContext context, org.jcodings.Encoding strEncoding) int
static int
getFModeFromString
(String modesString) Deprecated.getlineFast
(ThreadContext context, org.jcodings.Encoding enc, RubyIO io, boolean chomp) int
int
getMode()
getModeAsString
(Ruby runtime) Deprecated.getModeAsString
(ThreadContext context) static int
getModeFlagsAsIntFrom
(int fmode) getPath()
long
getPid()
static String
getStringFromMode
(int mode) void
incrementLineno
(Ruby runtime) Deprecated.void
incrementLineno
(Ruby runtime, RubyIO io) org.jcodings.Encoding
inputEncoding
(Ruby runtime) void
interruptBlockingThreads
(ThreadContext context) Fire an IOError in all threads blocking on this IO objectint
io_fflush
(ThreadContext context) int
static int
ioFmodeOflags
(int fmode) static int
ioModestrFmode
(Ruby runtime, String modestr) Deprecated.static int
ioModestrFmode
(ThreadContext context, String modestr) static int
ioModestrOflags
(Ruby runtime, String modestr) Deprecated.static int
ioModestrOflags
(ThreadContext context, String modestr) static String
ioOflagsModestr
(Ruby runtime, int oflags) Deprecated.static String
ioOflagsModestr
(ThreadContext context, int oflags) boolean
boolean
boolean
boolean
boolean
isBOM()
boolean
isDuplex()
boolean
isOpen()
boolean
boolean
boolean
isStdio()
boolean
isSync()
boolean
boolean
boolean
boolean
lock()
boolean
void
makeReadConversion
(ThreadContext context) void
makeReadConversion
(ThreadContext context, int size) void
makeWriteConversion
(ThreadContext context) int
moreChar
(ThreadContext context) boolean
void
boolean
boolean
boolean
needsWriteConversion
(ThreadContext context) static int
preadInternal
(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int from, int length) static int
pwriteInternal
(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int from, int length) static int
rbW32WriteConsole
(byte[] bytes, int start, int length, org.jcodings.Encoding encoding) static long
rbW32WriteConsole
(RubyString buffer) boolean
int
int
byte[]
int
void
READ_CHECK
(ThreadContext context) boolean
boolean
int
int
byte[]
int
readAll
(ThreadContext context, int siz, IRubyObject str) int
readBufferedData
(byte[] ptrBytes, int ptr, int len) org.jcodings.Encoding
readEncoding
(Ruby runtime) static int
readInternal
(ThreadContext context, OpenFile fptr, ChannelFD fd, byte[] bufBytes, int buf, int count) static int
readInternal
(ThreadContext context, OpenFile fptr, ChannelFD fd, ByteBuffer buffer, int buf, int count) int
boolean
ready
(Ruby runtime, RubyThread thread, int ops, long timeout) Wait until the channel is available for the given operations or the timeout expires.boolean
readyNow
(ThreadContext context) Likeready(org.jruby.Ruby, org.jruby.RubyThread, int, long)
but returns a result immediately.int
void
removeBlockingThread
(RubyThread thread) Remove a thread from the list of blocking threads for this IO.long
seek
(ThreadContext context, long offset, int whence) void
void
setAutoclose
(boolean autoclose) void
void
void
setBlocking
(Ruby runtime, boolean blocking) void
setBOM
(boolean bom) void
setChannel
(Channel fd) void
void
setFinalizer
(OpenFile.Finalizer finalizer) void
setLineNumber
(int lineNumber) void
setMode
(int modes) void
setNonblock
(Ruby runtime) void
void
setPid
(long pid) void
setProcess
(Process process) void
setSync
(boolean sync) void
shiftCbuf
(int len, RubyString str) shiftCbuf
(ThreadContext context, int len, IRubyObject strp) boolean
swallow
(ThreadContext context, int term) long
tell
(ThreadContext context) int
threadFlock
(ThreadContext context, int lockMode) void
ungetbyte
(ThreadContext context, IRubyObject str) void
unlock()
void
unread
(ThreadContext context) void
waitForBlockingThreads
(ThreadContext context) Wait until all blocking threads have exited their blocking area.boolean
waitReadable
(ThreadContext context) boolean
waitReadable
(ThreadContext context, long timeout) boolean
waitWritable
(ThreadContext context) boolean
waitWritable
(ThreadContext context, long timeout) static int
writeInternal
(ThreadContext context, OpenFile fptr, byte[] bufBytes, int buf, int count) static int
writeInternal
(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:
finalize
in interfaceFinalizable
- Overrides:
finalize
in 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.
-