jaulib v1.1.2-115-g39e35fd
Jau Support Library (C++, Java, ..)
|
File based byte input stream, including named file descriptor. More...
Public Member Functions | |
ByteInStream_File (final String path) | |
Construct a Stream-Based byte input stream from filesystem path. More... | |
ByteInStream_File (final int dirfd, final String path) | |
Construct a stream based byte input stream from filesystem path and parent directory file descriptor. More... | |
ByteInStream_File (final int fd) | |
Construct a stream based byte input stream by duplicating given file descriptor. More... | |
native void | closeStream () |
Close the stream if supported by the underlying mechanism. More... | |
void | close () |
Close the stream if supported by the underlying mechanism and dispose the native instance. More... | |
void | finalize () |
native boolean | is_open () |
Checks if the stream has an associated file. More... | |
void | clear (final IOState state) |
Clears state flags by assignment to the given value. More... | |
native int | fd () |
Returns the file descriptor if is_open(), otherwise -1 for no file descriptor. More... | |
IOState | rdState () |
Returns the current state flags. More... | |
void | setState (final IOState state) |
Sets state flags, by keeping its previous bits. More... | |
native boolean | good () |
Checks if no error nor eof() has occurred i.e. More... | |
native boolean | eof () |
Checks if end-of-file has been reached. More... | |
native boolean | fail () |
Checks if an error has occurred. More... | |
native boolean | bad () |
Checks if a non-recoverable error has occurred. More... | |
native boolean | timeout () |
Checks if a timeout (non-recoverable) has occurred. More... | |
native boolean | available (final long n) |
Return whether n bytes are available in the input stream, if has_content_size() or using an asynchronous source. More... | |
native int | read (final byte[] out, final int offset, final int length) |
Read from the source. More... | |
int | read (final ByteBuffer out) |
Read from the source. More... | |
native int | peek (byte[] out, final int offset, final int length, final long peek_offset) |
Read from the source but do not modify the internal offset. More... | |
native String | id () |
return the id of this data source More... | |
native long | discard_next (long N) |
Discard the next N bytes of the data. More... | |
native long | tellg () |
Returns the input position indicator, similar to std::basic_istream. More... | |
native boolean | has_content_size () |
Returns true if implementation is aware of content_size(), otherwise false. More... | |
native long | content_size () |
Returns the content_size if known. More... | |
native String | toString () |
boolean | is_open () |
Checks if the stream has an associated file. More... | |
void | closeStream () |
Close the stream if supported by the underlying mechanism. More... | |
void | close () |
Close the stream if supported by the underlying mechanism and dispose the native instance. More... | |
boolean | available (long n) |
Return whether n bytes are available in the input stream, if has_content_size() or using an asynchronous source. More... | |
int | read (byte out[], final int offset, final int length) |
Read from the source. More... | |
int | read (ByteBuffer out) |
Read from the source. More... | |
int | peek (byte out[], final int offset, final int length, final long peek_offset) |
Read from the source but do not modify the internal offset. More... | |
String | id () |
return the id of this data source More... | |
long | discard_next (long N) |
Discard the next N bytes of the data. More... | |
long | tellg () |
Returns the input position indicator, similar to std::basic_istream. More... | |
boolean | has_content_size () |
Returns true if implementation is aware of content_size(), otherwise false. More... | |
long | content_size () |
Returns the content_size if known. More... | |
String | toString () |
void | clear (final IOState state) |
Clears state flags by assignment to the given value. More... | |
IOState | rdState () |
Returns the current state flags. More... | |
void | setState (final IOState state) |
Sets state flags, by keeping its previous bits. More... | |
boolean | good () |
Checks if no error nor eof() has occurred i.e. More... | |
boolean | eof () |
Checks if end-of-file has been reached. More... | |
boolean | fail () |
Checks if an error has occurred. More... | |
boolean | bad () |
Checks if a non-recoverable error has occurred. More... | |
boolean | timeout () |
Checks if a timeout (non-recoverable) has occurred. More... | |
File based byte input stream, including named file descriptor.
Implementation mimics std::ifstream via OS level file descriptor (FD) operations, giving more flexibility, allowing reusing existing FD and enabling openat() operations.
If source path denotes a named file descriptor, i.e. jau::fs::file_stats::is_fd() returns true, has_content_size() returns false and available() returns true as long the stream is open and EOS hasn't occurred.
Instance uses the native C++ object jau::io::ByteInStream_File
.
Definition at line 39 of file ByteInStream_File.java.
org.jau.io.ByteInStream_File.ByteInStream_File | ( | final String | path | ) |
Construct a Stream-Based byte input stream from filesystem path.
In case the given path is a local file URI starting with file://
, see org.jau.io.UriTk#is_local_file_protocol(String)
, the leading file://
is cut off and the remainder being used.
path | the path to the file, maybe a local file URI |
Definition at line 51 of file ByteInStream_File.java.
org.jau.io.ByteInStream_File.ByteInStream_File | ( | final int | dirfd, |
final String | path | ||
) |
Construct a stream based byte input stream from filesystem path and parent directory file descriptor.
In case the given path is a local file URI starting with file://
, see jau::io::uri::is_local_file_protocol(), the leading file://
is cut off and the remainder being used.
dirfd | parent directory file descriptor |
path | the path to the file, maybe a local file URI |
Definition at line 70 of file ByteInStream_File.java.
org.jau.io.ByteInStream_File.ByteInStream_File | ( | final int | fd | ) |
Construct a stream based byte input stream by duplicating given file descriptor.
In case the given path is a local file URI starting with file://
, see jau::io::uri::is_local_file_protocol(), the leading file://
is cut off and the remainder being used.
fd | file descriptor to duplicate leaving the given fd untouched |
Definition at line 88 of file ByteInStream_File.java.
native boolean org.jau.io.ByteInStream_File.available | ( | final long | n | ) |
Return whether n bytes are available in the input stream, if has_content_size() or using an asynchronous source.
If !has_content_size() and not being an asynchronous source, !end_of_data() is returned.
Method may be blocking when using an asynchronous source up until the requested bytes are available.
A subsequent call to read() shall return immediately with at least the requested numbers of bytes available, if has_content_size() or using an asynchronous source.
See details of the implementing class.
n | byte count to wait for |
Implements org.jau.io.ByteInStream.
native boolean org.jau.io.ByteInStream_File.bad | ( | ) |
Checks if a non-recoverable error has occurred.
Implements org.jau.io.IOStateFunc.
void org.jau.io.ByteInStream_File.clear | ( | final IOState | state | ) |
Clears state flags by assignment to the given value.
Implements org.jau.io.IOStateFunc.
Definition at line 123 of file ByteInStream_File.java.
void org.jau.io.ByteInStream_File.close | ( | ) |
Close the stream if supported by the underlying mechanism and dispose the native instance.
Instance is unusable after having this method called.
Close the stream if supported by the underlying mechanism and dispose the native instance.Instance is unusable after having this method called.
Implements org.jau.io.ByteInStream.
Definition at line 102 of file ByteInStream_File.java.
native void org.jau.io.ByteInStream_File.closeStream | ( | ) |
Close the stream if supported by the underlying mechanism.
Native instance will not be disposed.
Close the stream if supported by the underlying mechanism.Native instance will not be disposed.
Implements org.jau.io.ByteInStream.
native long org.jau.io.ByteInStream_File.content_size | ( | ) |
native long org.jau.io.ByteInStream_File.discard_next | ( | long | N | ) |
Discard the next N bytes of the data.
N | the number of bytes to discard |
Implements org.jau.io.ByteInStream.
native boolean org.jau.io.ByteInStream_File.eof | ( | ) |
Checks if end-of-file has been reached.
Implements org.jau.io.IOStateFunc.
native boolean org.jau.io.ByteInStream_File.fail | ( | ) |
Checks if an error has occurred.
Implements org.jau.io.IOStateFunc.
native int org.jau.io.ByteInStream_File.fd | ( | ) |
void org.jau.io.ByteInStream_File.finalize | ( | ) |
native boolean org.jau.io.ByteInStream_File.good | ( | ) |
Checks if no error nor eof() has occurred i.e.
I/O operations are available.
Implements org.jau.io.IOStateFunc.
native boolean org.jau.io.ByteInStream_File.has_content_size | ( | ) |
Returns true if implementation is aware of content_size(), otherwise false.
Implements org.jau.io.ByteInStream.
native String org.jau.io.ByteInStream_File.id | ( | ) |
return the id of this data source
Implements org.jau.io.ByteInStream.
native boolean org.jau.io.ByteInStream_File.is_open | ( | ) |
Checks if the stream has an associated file.
Implements org.jau.io.ByteInStream.
native int org.jau.io.ByteInStream_File.peek | ( | byte[] | out, |
final int | offset, | ||
final int | length, | ||
final long | peek_offset | ||
) |
Read from the source but do not modify the internal offset.
Consecutive calls to peek() will return portions of the source starting at the same position.
out | the byte array to write the output to |
offset | offset to byte array to read into |
length | number of in bytes to read into starting at offset |
peek_offset | the offset into the stream to read at |
Implements org.jau.io.ByteInStream.
IOState org.jau.io.ByteInStream_File.rdState | ( | ) |
Returns the current state flags.
Method is marked virtual
to allow implementations with asynchronous resources to determine or update the current iostate.
Method is used throughout all query members and setstate(), hence they all will use the updated state from a potential override implementation.
Implements org.jau.io.IOStateFunc.
Definition at line 136 of file ByteInStream_File.java.
native int org.jau.io.ByteInStream_File.read | ( | final byte[] | out, |
final int | offset, | ||
final int | length | ||
) |
Read from the source.
Moves the internal offset so that every call to read will return a new portion of the source.
Use available() to try to wait for a certain amount of bytes available.
This method shall only block until min(available, length)
bytes are transfered.
See details of the implementing class.
out | the byte array to write the result to |
offset | offset to byte array to read into |
length | the length of the byte array out |
Implements org.jau.io.ByteInStream.
int org.jau.io.ByteInStream_File.read | ( | final ByteBuffer | out | ) |
Read from the source.
Moves the internal offset so that every call to read will return a new portion of the source.
Use available() to try to wait for a certain amount of bytes available.
This method shall only block until min(available, length)
bytes are transfered.
See details of the implementing class.
out | the direct ByteBuffer to write the result starting at its position up to its capacity . Limit will be set to position + read-bytes. |
limit
- position
, i.e. remaining
.Implements org.jau.io.ByteInStream.
Definition at line 169 of file ByteInStream_File.java.
void org.jau.io.ByteInStream_File.setState | ( | final IOState | state | ) |
Sets state flags, by keeping its previous bits.
Implements org.jau.io.IOStateFunc.
Definition at line 142 of file ByteInStream_File.java.
native long org.jau.io.ByteInStream_File.tellg | ( | ) |
Returns the input position indicator, similar to std::basic_istream.
Implements org.jau.io.ByteInStream.
native boolean org.jau.io.ByteInStream_File.timeout | ( | ) |
Checks if a timeout (non-recoverable) has occurred.
Implements org.jau.io.IOStateFunc.
native String org.jau.io.ByteInStream_File.toString | ( | ) |
Implements org.jau.io.ByteInStream.