jaulib v1.1.2-115-g39e35fd
Jau Support Library (C++, Java, ..)
Public Member Functions | List of all members
org.jau.io.ByteOutStream_File Class Reference

File based byte output stream, including named file descriptor. More...

Inheritance diagram for org.jau.io.ByteOutStream_File:
Collaboration diagram for org.jau.io.ByteOutStream_File:

Public Member Functions

 ByteOutStream_File (final String path, final FMode mode)
 Construct a stream based byte output stream from filesystem path, either an existing or new file. More...
 
 ByteOutStream_File (final int dirfd, final String path, final FMode mode)
 Construct a stream based byte output stream from filesystem path and parent directory file descriptor, either an existing or new file. More...
 
 ByteOutStream_File (final int fd)
 Construct a stream based byte output 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 int write (final byte[] in, final int offset, final int length)
 Write to the data sink. More...
 
int write (final ByteBuffer in)
 Write to the data sink. More...
 
native String id ()
 return the id of this data source More...
 
native long tellp ()
 Returns the output position indicator. 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...
 
int write (byte in[], final int offset, final int length)
 Write to the data sink. More...
 
int write (ByteBuffer in)
 Write to the data sink. More...
 
String id ()
 return the id of this data source More...
 
long tellp ()
 Returns the output position indicator. 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...
 

Detailed Description

File based byte output 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.

Instance uses the native C++ object jau::io::ByteOutStream_File.

Definition at line 38 of file ByteOutStream_File.java.

Constructor & Destructor Documentation

◆ ByteOutStream_File() [1/3]

org.jau.io.ByteOutStream_File.ByteOutStream_File ( final String  path,
final FMode  mode 
)

Construct a stream based byte output stream from filesystem path, either an existing or new file.

In case the file already exists, the underlying file offset is positioned at the end of the file.

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.

Parameters
paththe path to the file, maybe a local file URI
modefile protection mode for a new file, otherwise ignored, may use FMode#def_file.

Definition at line 54 of file ByteOutStream_File.java.

◆ ByteOutStream_File() [2/3]

org.jau.io.ByteOutStream_File.ByteOutStream_File ( final int  dirfd,
final String  path,
final FMode  mode 
)

Construct a stream based byte output stream from filesystem path and parent directory file descriptor, either an existing or new file.

In case the file already exists, the underlying file offset is positioned at the end of the file.

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.

Parameters
dirfdparent directory file descriptor
paththe path to the file, maybe a local file URI
modefile protection mode for a new file, otherwise ignored, may use FMode#def_file.

Definition at line 77 of file ByteOutStream_File.java.

◆ ByteOutStream_File() [3/3]

org.jau.io.ByteOutStream_File.ByteOutStream_File ( final int  fd)

Construct a stream based byte output 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.

Parameters
fdfile descriptor to duplicate leaving the given fd untouched

Definition at line 95 of file ByteOutStream_File.java.

Here is the call graph for this function:

Member Function Documentation

◆ bad()

native boolean org.jau.io.ByteOutStream_File.bad ( )

Checks if a non-recoverable error has occurred.

Implements org.jau.io.IOStateFunc.

◆ clear()

void org.jau.io.ByteOutStream_File.clear ( final IOState  state)

Clears state flags by assignment to the given value.

Implements org.jau.io.IOStateFunc.

Definition at line 130 of file ByteOutStream_File.java.

◆ close()

void org.jau.io.ByteOutStream_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.ByteOutStream.

Definition at line 109 of file ByteOutStream_File.java.

Here is the caller graph for this function:

◆ closeStream()

native void org.jau.io.ByteOutStream_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.ByteOutStream.

◆ eof()

native boolean org.jau.io.ByteOutStream_File.eof ( )

Checks if end-of-file has been reached.

Implements org.jau.io.IOStateFunc.

◆ fail()

native boolean org.jau.io.ByteOutStream_File.fail ( )

Checks if an error has occurred.

Implements org.jau.io.IOStateFunc.

◆ fd()

native int org.jau.io.ByteOutStream_File.fd ( )

Returns the file descriptor if is_open(), otherwise -1 for no file descriptor.

See also
is_open()
Here is the caller graph for this function:

◆ finalize()

void org.jau.io.ByteOutStream_File.finalize ( )

Definition at line 122 of file ByteOutStream_File.java.

Here is the call graph for this function:

◆ good()

native boolean org.jau.io.ByteOutStream_File.good ( )

Checks if no error nor eof() has occurred i.e.

I/O operations are available.

Implements org.jau.io.IOStateFunc.

◆ id()

native String org.jau.io.ByteOutStream_File.id ( )

return the id of this data source

Returns
std::string representing the id of this data source

Implements org.jau.io.ByteOutStream.

◆ is_open()

native boolean org.jau.io.ByteOutStream_File.is_open ( )

Checks if the stream has an associated file.

Implements org.jau.io.ByteOutStream.

◆ rdState()

IOState org.jau.io.ByteOutStream_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 143 of file ByteOutStream_File.java.

◆ setState()

void org.jau.io.ByteOutStream_File.setState ( final IOState  state)

Sets state flags, by keeping its previous bits.

Implements org.jau.io.IOStateFunc.

Definition at line 149 of file ByteOutStream_File.java.

◆ tellp()

native long org.jau.io.ByteOutStream_File.tellp ( )

Returns the output position indicator.

Returns
number of bytes written so far.

Implements org.jau.io.ByteOutStream.

◆ timeout()

native boolean org.jau.io.ByteOutStream_File.timeout ( )

Checks if a timeout (non-recoverable) has occurred.

Implements org.jau.io.IOStateFunc.

◆ toString()

native String org.jau.io.ByteOutStream_File.toString ( )

Implements org.jau.io.ByteOutStream.

Here is the caller graph for this function:

◆ write() [1/2]

native int org.jau.io.ByteOutStream_File.write ( final byte[]  in,
final int  offset,
final int  length 
)

Write to the data sink.

Moves the internal offset so that every call to write will be appended to the sink.

This method is not blocking beyond the transfer length bytes.

Parameters
inthe input bytes to write out
offsetoffset to byte array to write out
lengththe length of the byte array in
Returns
length in bytes that were actually written

Implements org.jau.io.ByteOutStream.

◆ write() [2/2]

int org.jau.io.ByteOutStream_File.write ( final ByteBuffer  in)

Write to the data sink.

Moves the internal offset so that every call to write will be appended to the sink.

This method is not blocking beyond the transfer length bytes.

Parameters
inthe direct ByteBuffer source to be written to the sink from position up to its limit, i.e. remaining. Position will be set to position + written-bytes.
Returns
length in bytes that were actually written, equal to its current position - previous position.

Implements org.jau.io.ByteOutStream.

Definition at line 173 of file ByteOutStream_File.java.

Here is the call graph for this function:

The documentation for this class was generated from the following file: