< prev index next >

src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java

Print this page

        

@@ -28,10 +28,12 @@
 import java.io.FileDescriptor;
 import java.io.IOException;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.misc.JavaIOFileDescriptorAccess;
 import sun.security.action.GetPropertyAction;
+import java.io.File;
+import java.nio.CharBuffer;
 
 class FileDispatcherImpl extends FileDispatcher {
 
     private static final JavaIOFileDescriptorAccess fdAccess =
         SharedSecrets.getJavaIOFileDescriptorAccess();

@@ -121,10 +123,25 @@
 
     boolean transferToDirectlyNeedsPositionLock() {
         return true;
     }
 
+    int setDirectIO(FileDescriptor fd, String path)
+    {
+        int result = -1;
+        String filePath = path.substring(0, path.lastIndexOf(File.separator));
+        CharBuffer buffer = CharBuffer.allocate(filePath.length());
+        buffer.put(filePath);
+        try {
+            result = setDirect0(fd, buffer);
+        } catch (IOException e) {
+            throw new UnsupportedOperationException
+                ("Error setting up DirectIO", e);
+        }
+        return result;
+    }
+
     static boolean isFastFileTransferRequested() {
         String fileTransferProp = GetPropertyAction
                 .privilegedGetProperty("jdk.nio.enableFastFileTransfer");
         boolean enable;
         if ("".equals(fileTransferProp)) {

@@ -175,6 +192,8 @@
         throws IOException;
 
     static native void close0(FileDescriptor fd) throws IOException;
 
     static native long duplicateHandle(long fd) throws IOException;
+
+    static native int setDirect0(FileDescriptor fd, CharBuffer buffer) throws IOException;
 }
< prev index next >