26import java.nio.ByteBuffer;
28import org.jau.fs.FMode;
39 private volatile long nativeInstance;
40 long getNativeInstance() {
return nativeInstance; }
56 nativeInstance = ctorImpl1(path, mode.
mask);
57 }
catch (
final Throwable t) {
58 System.err.println(
"ByteOutStream_File.ctor: native ctor failed: "+t.getMessage());
62 private static native
long ctorImpl1(
final String path,
int mode);
79 nativeInstance = ctorImpl2(dirfd, path, mode.
mask);
80 }
catch (
final Throwable t) {
81 System.err.println(
"ByteOutStream_File.ctor: native ctor failed: "+t.getMessage());
85 private static native
long ctorImpl2(
final int dirfd,
final String path,
int mode);
97 nativeInstance = ctorImpl3(
fd);
98 }
catch (
final Throwable t) {
99 System.err.println(
"ByteOutStream_File.ctor: native ctor failed: "+t.getMessage());
103 private static native
long ctorImpl3(
final int fd);
111 synchronized( this ) {
112 handle = nativeInstance;
119 private static native
void dtorImpl(
final long nativeInstance);
131 clearImpl( state.
mask );
133 private native
void clearImpl(
int s);
140 public native
int fd();
144 return new IOState( rdStateImpl() );
146 private native
int rdStateImpl();
150 setStateImpl( state.
mask );
152 private native
void setStateImpl(
int s);
158 public native
boolean eof();
164 public native
boolean bad();
170 public native
int write(
final byte[] in,
final int offset,
final int length);
173 public int write(
final ByteBuffer in) {
175 throw new IllegalArgumentException(
"in buffer not direct");
178 in.position(in.position() + res);
181 private native
int write2Impl(Object in,
int in_offset,
int in_limit);
184 public native String
id();
Generic file type and POSIX protection mode bits as used in file_stats, touch(), mkdir() etc.
Utility methods allowing easy java.nio.Buffer manipulations.
static boolean isDirect(final Object buf)
Helper routine to tell whether a buffer is direct or not.
static long getDirectBufferByteOffset(final Object buf)
Helper routine to get the Buffer byte offset by taking into account the Buffer position and the under...
static long getDirectBufferByteLimit(final Object buf)
Helper routine to get the Buffer byte limit by taking into account the Buffer limit and the underlyin...
File based byte output stream, including named file descriptor.
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...
native boolean is_open()
Checks if the stream has an associated file.
native int fd()
Returns the file descriptor if is_open(), otherwise -1 for no file descriptor.
int write(final ByteBuffer in)
Write to the data sink.
native long tellp()
Returns the output position indicator.
native boolean bad()
Checks if a non-recoverable error has occurred.
void setState(final IOState state)
Sets state flags, by keeping its previous bits.
native boolean timeout()
Checks if a timeout (non-recoverable) has occurred.
native String id()
return the id of this data source
ByteOutStream_File(final String path, final FMode mode)
Construct a stream based byte output stream from filesystem path, either an existing or new file.
void close()
Close the stream if supported by the underlying mechanism and dispose the native instance.
native boolean eof()
Checks if end-of-file has been reached.
IOState rdState()
Returns the current state flags.
void clear(final IOState state)
Clears state flags by assignment to the given value.
ByteOutStream_File(final int fd)
Construct a stream based byte output stream by duplicating given file descriptor.
native void closeStream()
Close the stream if supported by the underlying mechanism.
native boolean good()
Checks if no error nor eof() has occurred i.e.
native int write(final byte[] in, final int offset, final int length)
Write to the data sink.
native boolean fail()
Checks if an error has occurred.
Mimic std::ios_base::iostate for state functionality, see iostate_func.
Abstract byte output stream object, to write data to a sink.