public class ChannelStream extends Object implements Stream, Finalizable
Modifier and Type | Field and Description |
---|---|
protected ByteBuffer |
buffer |
static int |
BUFSIZE
The size of the read/write buffer allocated for this stream.
|
protected ModeFlags |
modes |
protected boolean |
reading |
protected boolean |
sync |
PARAGRAPH_DELIMETER, PARAGRAPH_SEPARATOR, SEEK_CUR, SEEK_END, SEEK_SET
Modifier and Type | Method and Description |
---|---|
void |
checkPermissionsSubsetOf(ModeFlags subsetModes) |
void |
checkReadable() |
void |
checkWritable() |
void |
clearerr() |
void |
fclose()
Closes IO handler resources.
|
static Stream |
fdopen(Ruby runtime,
ChannelDescriptor descriptor,
ModeFlags modes) |
static Stream |
fdopen(Ruby runtime,
ChannelDescriptor descriptor,
ModeFlags modes,
boolean autoclose) |
boolean |
feof()
Return true when at end of file (EOF).
|
int |
fflush() |
int |
fgetc() |
long |
fgetpos()
Get the current position within the file associated with this
handler.
|
org.jruby.util.ByteList |
fgets(org.jruby.util.ByteList separatorString) |
void |
finalize()
Ensure close (especially flush) when we're finished with.
|
static Stream |
fopen(Ruby runtime,
String path,
ModeFlags modes) |
void |
fputc(int c) |
org.jruby.util.ByteList |
fread(int number) |
void |
freopen(Ruby runtime,
String path,
ModeFlags modes) |
void |
ftruncate(long newLength) |
int |
fwrite(org.jruby.util.ByteList string) |
Channel |
getChannel() |
ChannelDescriptor |
getDescriptor() |
int |
getline(org.jruby.util.ByteList dst,
byte terminator)
Read all bytes up to and including a terminator byte.
|
int |
getline(org.jruby.util.ByteList dst,
byte terminator,
long limit)
Reads all bytes up to and including a terminator byte or until limit is reached.
|
ModeFlags |
getModes() |
Ruby |
getRuntime() |
boolean |
isAutoclose() |
boolean |
isBinmode() |
boolean |
isBlocking() |
boolean |
isSync() |
void |
lseek(long offset,
int type)
Implementation of libc "lseek", which seeks on seekable streams, raises
EPIPE if the fd is assocated with a pipe, socket, or FIFO, and doesn't
do anything for other cases (like stdio).
|
InputStream |
newInputStream() |
OutputStream |
newOutputStream() |
static Stream |
open(Ruby runtime,
ChannelDescriptor descriptor) |
static Stream |
open(Ruby runtime,
ChannelDescriptor descriptor,
boolean autoclose) |
int |
read() |
int |
read(ByteBuffer dst) |
int |
read(ByteBuffer dst,
boolean partial) |
org.jruby.util.ByteList |
read(int number) |
org.jruby.util.ByteList |
readall()
Deprecated.
readall do busy loop for the IO which has NONBLOCK bit. You
should implement the logic by yourself with fread().
|
boolean |
readDataBuffered() |
org.jruby.util.ByteList |
readnonblock(int number) |
org.jruby.util.ByteList |
readpartial(int number) |
int |
ready()
Implement IO#ready? as per io/wait in MRI.
|
void |
setAutoclose(boolean autoclose) |
void |
setBinmode() |
void |
setBlocking(boolean block) |
void |
setModes(ModeFlags modes) |
void |
setSync(boolean sync) |
void |
sync()
Flush and sync all writes to the filesystem.
|
int |
ungetc(int c) |
void |
waitUntilReady()
Implement IO#wait as per io/wait in MRI.
|
int |
write(ByteBuffer buf) |
boolean |
writeDataBuffered() |
int |
writenonblock(org.jruby.util.ByteList buf) |
public static final int BUFSIZE
protected ModeFlags modes
protected boolean sync
protected volatile ByteBuffer buffer
protected boolean reading
public Ruby getRuntime()
public void checkReadable() throws IOException
IOException
public void checkWritable() throws IOException
IOException
public void checkPermissionsSubsetOf(ModeFlags subsetModes)
public void setBinmode()
setBinmode
in interface Stream
public boolean isAutoclose()
isAutoclose
in interface Stream
public void setAutoclose(boolean autoclose)
setAutoclose
in interface Stream
public void waitUntilReady() throws IOException, InterruptedException
waitUntilReady
in interface Stream
IOException
InterruptedException
public boolean readDataBuffered()
readDataBuffered
in interface Stream
public boolean writeDataBuffered()
writeDataBuffered
in interface Stream
public org.jruby.util.ByteList fgets(org.jruby.util.ByteList separatorString) throws IOException, BadDescriptorException
fgets
in interface Stream
IOException
BadDescriptorException
public int getline(org.jruby.util.ByteList dst, byte terminator) throws IOException, BadDescriptorException
Stream
If the terminator byte is found, it will be the last byte in the output buffer.
getline
in interface Stream
dst
- The output buffer.terminator
- The byte to terminate reading.IOException
BadDescriptorException
public int getline(org.jruby.util.ByteList dst, byte terminator, long limit) throws IOException, BadDescriptorException
Stream
If the terminator byte is found, it will be the last byte in the output buffer.
getline
in interface Stream
dst
- The output buffer.terminator
- The byte to terminate reading.limit
- the number of bytes to read unless EOF or terminator is foundIOException
BadDescriptorException
@Deprecated public org.jruby.util.ByteList readall() throws IOException, BadDescriptorException
readall
in interface Stream
IOException
BadDescriptorException
public void fclose() throws IOException, BadDescriptorException
fclose
in interface Stream
IOException
BadDescriptorException
public int fflush() throws IOException, BadDescriptorException
fflush
in interface Stream
IOException
BadDescriptorException
public InputStream newInputStream()
newInputStream
in interface Stream
public OutputStream newOutputStream()
newOutputStream
in interface Stream
public boolean feof() throws IOException, BadDescriptorException
Stream
Return true when at end of file (EOF).
feof
in interface Stream
IOException
BadDescriptorException
public long fgetpos() throws IOException, PipeException, InvalidValueException, BadDescriptorException
Stream
Get the current position within the file associated with this handler.
fgetpos
in interface Stream
IOException
PipeException
- ESPIPE (illegal seek) when not a fileInvalidValueException
BadDescriptorException
public void lseek(long offset, int type) throws IOException, InvalidValueException, PipeException, BadDescriptorException
lseek
in interface Stream
IOException
InvalidValueException
PipeException
BadDescriptorException
public void sync() throws IOException, BadDescriptorException
Stream
Flush and sync all writes to the filesystem.
sync
in interface Stream
IOException
- if the sync does not workBadDescriptorException
public org.jruby.util.ByteList read(int number) throws IOException, BadDescriptorException
read
in interface Stream
IOException
BadDescriptorException
public void ftruncate(long newLength) throws IOException, BadDescriptorException, InvalidValueException
ftruncate
in interface Stream
IOException
BadDescriptorException
InvalidValueException
public void finalize() throws Throwable
finalize
in interface Finalizable
finalize
in class Object
Throwable
public int ready() throws IOException
Stream
ready
in interface Stream
IOException
public void fputc(int c) throws IOException, BadDescriptorException
fputc
in interface Stream
IOException
BadDescriptorException
public int fgetc() throws IOException, BadDescriptorException
fgetc
in interface Stream
IOException
BadDescriptorException
public int fwrite(org.jruby.util.ByteList string) throws IOException, BadDescriptorException
fwrite
in interface Stream
IOException
BadDescriptorException
public int write(ByteBuffer buf) throws IOException, BadDescriptorException
IOException
BadDescriptorException
public int writenonblock(org.jruby.util.ByteList buf) throws IOException, BadDescriptorException
IOException
BadDescriptorException
public org.jruby.util.ByteList fread(int number) throws IOException, BadDescriptorException
fread
in interface Stream
IOException
BadDescriptorException
public org.jruby.util.ByteList readnonblock(int number) throws IOException, BadDescriptorException, EOFException
public org.jruby.util.ByteList readpartial(int number) throws IOException, BadDescriptorException, EOFException
public int read(ByteBuffer dst) throws IOException, BadDescriptorException, EOFException
public int read(ByteBuffer dst, boolean partial) throws IOException, BadDescriptorException, EOFException
public int read() throws IOException, BadDescriptorException
IOException
BadDescriptorException
public ChannelDescriptor getDescriptor()
getDescriptor
in interface Stream
public void setBlocking(boolean block) throws IOException
setBlocking
in interface Stream
IOException
public boolean isBlocking()
isBlocking
in interface Stream
public void freopen(Ruby runtime, String path, ModeFlags modes) throws DirectoryAsFileException, IOException, InvalidValueException, PipeException, BadDescriptorException
freopen
in interface Stream
DirectoryAsFileException
IOException
InvalidValueException
PipeException
BadDescriptorException
public static Stream open(Ruby runtime, ChannelDescriptor descriptor)
public static Stream fdopen(Ruby runtime, ChannelDescriptor descriptor, ModeFlags modes) throws InvalidValueException
InvalidValueException
public static Stream open(Ruby runtime, ChannelDescriptor descriptor, boolean autoclose)
public static Stream fdopen(Ruby runtime, ChannelDescriptor descriptor, ModeFlags modes, boolean autoclose) throws InvalidValueException
InvalidValueException
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException
public Channel getChannel()
getChannel
in interface Stream
Copyright © 2001-2013 JRuby. All Rights Reserved.