< prev index next >

src/java.base/unix/native/libjava/FileOutputStream_md.c

Print this page

        

@@ -36,29 +36,36 @@
 /*******************************************************************/
 /*  BEGIN JNI ********* BEGIN JNI *********** BEGIN JNI ************/
 /*******************************************************************/
 
 jfieldID fos_fd; /* id for jobject 'fd' in java.io.FileOutputStream */
+jfieldID fos_pgsz; /* id for jobject 'pageSize' in java.io.FileOutputStream */
 
 /**************************************************************
  * static methods to store field ID's in initializers
  */
 
 JNIEXPORT void JNICALL
 Java_java_io_FileOutputStream_initIDs(JNIEnv *env, jclass fdClass) {
     fos_fd = (*env)->GetFieldID(env, fdClass, "fd", "Ljava/io/FileDescriptor;");
+    fos_pgsz = (*env)->GetFieldID(env, fdClass, "pageSize", "I");
 }
 
 /**************************************************************
  * Output stream
  */
 
 JNIEXPORT void JNICALL
 Java_java_io_FileOutputStream_open0(JNIEnv *env, jobject this,
-                                    jstring path, jboolean append) {
+                                    jstring path, jboolean append, jboolean direct) {
+    if (direct) { 
+        fileOpen(env, this, path, fos_fd,
+             O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC) | O_DIRECT);
+    } else {
     fileOpen(env, this, path, fos_fd,
              O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC));
+    }
 }
 
 JNIEXPORT void JNICALL
 Java_java_io_FileOutputStream_write(JNIEnv *env, jobject this, jint byte, jboolean append) {
     writeSingle(env, this, byte, append, fos_fd);

@@ -69,8 +76,36 @@
     jobject this, jbyteArray bytes, jint off, jint len, jboolean append) {
     writeBytes(env, this, bytes, off, len, append, fos_fd);
 }
 
 JNIEXPORT void JNICALL
+Java_java_io_FileOutputStream_writeBytesD(JNIEnv *env,
+    jobject this, jbyteArray bytes, jint off, jint len, jboolean append) {
+    writeBytesD(env, this, bytes, off, len, append, fos_fd, fos_pgsz);
+}
+
+JNIEXPORT jint JNICALL
+Java_java_io_FileOutputStream_getPageSize0(JNIEnv *env, jobject this) {
+    return getpagesize();
+}
+
+JNIEXPORT void JNICALL
 Java_java_io_FileOutputStream_close0(JNIEnv *env, jobject this) {
     fileClose(env, this, fos_fd);
 }
+
+JNIEXPORT jlong JNICALL
+Java_java_io_FileOutputStream_getCurrentLocation0(JNIEnv *env, jobject this) {
+    FD fd;
+
+    fd = GET_FD(this, fos_fd);
+    if (fd == -1) {
+        JNU_ThrowIOException(env, "Stream Closed");
+        return -1;
+    }
+    jlong currentLocation = IO_Lseek(fd, 0, SEEK_CUR);
+    if (currentLocation == -1) {
+        JNU_ThrowIOExceptionWithLastError(env, "Seek failed");
+    }
+    return currentLocation;
+}
+
< prev index next >