< prev index next >

src/java.base/windows/classes/sun/nio/fs/WindowsPath.java

Print this page

        

@@ -23,10 +23,11 @@
  * questions.
  */
 
 package sun.nio.fs;
 
+import java.nio.charset.StandardCharsets;
 import java.nio.file.*;
 import java.nio.file.attribute.*;
 import java.io.*;
 import java.net.URI;
 import java.util.*;

@@ -68,10 +69,12 @@
     private volatile Integer[] offsets;
 
     // computed hash code (computed lazily, no need to be volatile)
     private int hash;
 
+    // UTF-8 path only calculated if required
+    private byte[] utf8path;
 
     /**
      * Initializes a new instance of this class.
      */
     private WindowsPath(WindowsFileSystem fs,

@@ -169,10 +172,17 @@
     // use this path for permission checks
     String getPathForPermissionCheck() {
         return path;
     }
 
+    synchronized byte[] getUTF8Path() {
+        if (utf8path == null) {
+            utf8path = path.getBytes(StandardCharsets.UTF_8);
+        }
+        return utf8path;
+    }
+
     // use this path for Win32 calls
     // This method will prefix long paths with \\?\ or \\?\UNC as required.
     String getPathForWin32Calls() throws WindowsException {
         // short absolute paths can be used directly
         if (isAbsolute() && path.length() <= MAX_PATH)
< prev index next >