aboutsummaryrefslogtreecommitdiffstats
path: root/java_jni/org
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-07-31 21:47:00 +0200
committerSven Gothel <[email protected]>2022-07-31 21:47:00 +0200
commit1a5e5b552ef6922d2f3a814862c2b13bbeb1b93b (patch)
tree8e4a9f163cbad77f2d9784cdb16b4a27e1895db9 /java_jni/org
parent600b44da6e0214630b1deadf38d4a99b81efa46e (diff)
ByteInStream_File: Remove obsolete `use_binary` arg, byte streams are always binary; Java: Add dirfd and fd ctor variants
Diffstat (limited to 'java_jni/org')
-rw-r--r--java_jni/org/jau/io/ByteInStream_File.java40
1 files changed, 32 insertions, 8 deletions
diff --git a/java_jni/org/jau/io/ByteInStream_File.java b/java_jni/org/jau/io/ByteInStream_File.java
index 5e1f024..4b30431 100644
--- a/java_jni/org/jau/io/ByteInStream_File.java
+++ b/java_jni/org/jau/io/ByteInStream_File.java
@@ -38,7 +38,7 @@ public final class ByteInStream_File implements ByteInStream {
/* pp */ long getNativeInstance() { return nativeInstance; }
/**
- * Construct a Stream-Based byte input stream from filesystem path treating file as binary.
+ * Construct a Stream-Based byte input stream from filesystem path
*
* In case the given path is a local file URI starting with `file://`, see {@link org.jau.io.UriTk#is_local_file_protocol(String)},
* the leading `file://` is cut off and the remainder being used.
@@ -46,27 +46,51 @@ public final class ByteInStream_File implements ByteInStream {
* @param path the path to the file, maybe a local file URI
*/
public ByteInStream_File(final String path) {
- this(path, true);
+ try {
+ nativeInstance = ctorImpl1(path);
+ } catch (final Throwable t) {
+ System.err.println("ByteInStream_File.ctor: native ctor failed: "+t.getMessage());
+ throw t;
+ }
}
+ private native long ctorImpl1(final String path);
/**
- * Construct a Stream-Based byte input stream from filesystem 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 {@link org.jau.io.UriTk#is_local_file_protocol(String)},
+ * 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.
*
+ * @param dirfd parent directory file descriptor
* @param path the path to the file, maybe a local file URI
- * @param use_binary whether to treat the file as binary (default) or use platform character conversion
*/
- public ByteInStream_File(final String path, final boolean use_binary) {
+ public ByteInStream_File(final int dirfd, final String path) {
+ try {
+ nativeInstance = ctorImpl2(dirfd, path);
+ } catch (final Throwable t) {
+ System.err.println("ByteInStream_File.ctor: native ctor failed: "+t.getMessage());
+ throw t;
+ }
+ }
+ private native long ctorImpl2(final int dirfd, final String path);
+
+ /**
+ * 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.
+ *
+ * @param fd file descriptor to duplicate leaving the given `fd` untouched
+ */
+ public ByteInStream_File(final int fd) {
try {
- nativeInstance = ctorImpl(path, use_binary);
+ nativeInstance = ctorImpl3(fd);
} catch (final Throwable t) {
System.err.println("ByteInStream_File.ctor: native ctor failed: "+t.getMessage());
throw t;
}
}
- private native long ctorImpl(final String path, final boolean use_binary);
+ private native long ctorImpl3(final int fd);
@Override
public native void closeStream();