< prev index next >

src/java.base/windows/classes/java/io/WinNTFileSystem.java

Print this page
*** 28,10 ***
--- 28,11 ---
  import java.io.File;
  import java.nio.file.Path;
  import java.util.BitSet;
  import java.util.Locale;
  import java.util.Properties;
+ import jdk.internal.misc.Blocker;
  import sun.security.action.GetPropertyAction;
  
  /**
   * Unicode-aware FileSystem for Windows NT/2000.
   *

*** 412,11 ***
              if ((c >= 'A') && (c <= 'Z'))
                  return path;
              return "" + ((char) (c-32)) + ':' + '\\';
          }
          if (!useCanonCaches) {
!             return canonicalize0(path);
          } else {
              String res = cache.get(path);
              if (res == null) {
                  String dir = null;
                  String resDir = null;
--- 413,15 ---
              if ((c >= 'A') && (c <= 'Z'))
                  return path;
              return "" + ((char) (c-32)) + ':' + '\\';
          }
          if (!useCanonCaches) {
!             if (Thread.currentThread().isVirtual()) {
+                 return Blocker.managedBlock(() -> canonicalize0(path));
+             } else {
+                 return canonicalize0(path);
+             }
          } else {
              String res = cache.get(path);
              if (res == null) {
                  String dir = null;
                  String resDir = null;

*** 529,42 ***
      }
  
      /* -- Attribute accessors -- */
  
      @Override
!     public native int getBooleanAttributes(File f);
  
      @Override
!     public native boolean checkAccess(File f, int access);
  
      @Override
!     public native long getLastModifiedTime(File f);
  
      @Override
!     public native long getLength(File f);
  
      @Override
!     public native boolean setPermission(File f, int access, boolean enable,
!             boolean owneronly);
  
      /* -- File operations -- */
  
      @Override
!     public native boolean createFileExclusively(String path)
!             throws IOException;
  
      @Override
!     public native String[] list(File f);
  
      @Override
!     public native boolean createDirectory(File f);
  
      @Override
!     public native boolean setLastModifiedTime(File f, long time);
  
      @Override
!     public native boolean setReadOnly(File f);
  
      @Override
      public boolean delete(File f) {
          // Keep canonicalization caches in sync after file deletion
          // and renaming operations. Could be more clever than this
--- 534,110 ---
      }
  
      /* -- Attribute accessors -- */
  
      @Override
!     public int getBooleanAttributes(File f) {
+         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> getBooleanAttributes0(f));
+         } else {
+             return getBooleanAttributes0(f);
+         }
+     }
+     private native int getBooleanAttributes0(File f);
  
      @Override
!     public boolean checkAccess(File f, int access) {
+         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> checkAccess0(f, access));
+         } else {
+             return checkAccess0(f, access);
+         }
+     }
+     private native boolean checkAccess0(File f, int access);
  
      @Override
!     public long getLastModifiedTime(File f) {
+         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> getLastModifiedTime0(f));
+         } else {
+             return getLastModifiedTime0(f);
+         }
+     }
+     private native long getLastModifiedTime0(File f);
  
      @Override
!     public long getLength(File f) {
+         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> getLength0(f));
+         } else {
+             return getLength0(f);
+         }
+     }
+     private native long getLength0(File f);
  
      @Override
!     public boolean setPermission(File f, int access, boolean enable, boolean owneronly) {
!         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> setPermission0(f, access, enable, owneronly));
+         } else {
+             return setPermission0(f, access, enable, owneronly);
+         }
+     }
+     private native boolean setPermission0(File f, int access, boolean enable, boolean owneronly);
  
      /* -- File operations -- */
  
      @Override
!     public boolean createFileExclusively(String path) throws IOException {
!         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> createFileExclusively0(path));
+         } else {
+             return createFileExclusively0(path);
+         }
+     }
+     private native boolean createFileExclusively0(String path) throws IOException;
  
      @Override
!     public String[] list(File f) {
+         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> list0(f));
+         } else {
+             return list0(f);
+         }
+     }
+     private native String[] list0(File f);
  
      @Override
!     public boolean createDirectory(File f) {
+         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> createDirectory0(f));
+         } else {
+             return createDirectory0(f);
+         }
+     }
+     private native boolean createDirectory0(File f);
  
      @Override
!     public boolean setLastModifiedTime(File f, long time) {
+         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> setLastModifiedTime0(f, time));
+         } else {
+             return setLastModifiedTime0(f, time);
+         }
+     }
+     private native boolean setLastModifiedTime0(File f, long time);
  
      @Override
!     public boolean setReadOnly(File f) {
+         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> setReadOnly0(f));
+         } else {
+             return setReadOnly0(f);
+         }
+     }
+     private native boolean setReadOnly0(File f);
  
      @Override
      public boolean delete(File f) {
          // Keep canonicalization caches in sync after file deletion
          // and renaming operations. Could be more clever than this

*** 575,13 ***
              cache.clear();
          }
          if (useCanonPrefixCache) {
              prefixCache.clear();
          }
!         return delete0(f);
      }
- 
      private native boolean delete0(File f);
  
      @Override
      public boolean rename(File f1, File f2) {
          // Keep canonicalization caches in sync after file deletion
--- 648,16 ---
              cache.clear();
          }
          if (useCanonPrefixCache) {
              prefixCache.clear();
          }
!         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> delete0(f));
+         } else {
+             return delete0(f);
+         }
      }
      private native boolean delete0(File f);
  
      @Override
      public boolean rename(File f1, File f2) {
          // Keep canonicalization caches in sync after file deletion

*** 593,13 ***
              cache.clear();
          }
          if (useCanonPrefixCache) {
              prefixCache.clear();
          }
!         return rename0(f1, f2);
      }
- 
      private native boolean rename0(File f1, File f2);
  
      /* -- Filesystem interface -- */
  
      @Override
--- 669,16 ---
              cache.clear();
          }
          if (useCanonPrefixCache) {
              prefixCache.clear();
          }
!         if (Thread.currentThread().isVirtual()) {
+             return Blocker.managedBlock(() -> rename0(f1, f2));
+         } else {
+             return rename0(f1, f2);
+         }
      }
      private native boolean rename0(File f1, File f2);
  
      /* -- Filesystem interface -- */
  
      @Override

*** 609,11 ***
              .stream()
              .mapToObj(i -> new File((char)('A' + i) + ":" + slash))
              .filter(f -> access(f.getPath()) && f.exists())
              .toArray(File[]::new);
      }
- 
      private static native int listRoots0();
  
      private boolean access(String path) {
          try {
              @SuppressWarnings("removal")
--- 688,10 ---

*** 632,11 ***
          if (f.exists()) {
              return getSpace0(f, t);
          }
          return 0;
      }
- 
      private native long getSpace0(File f, int t);
  
      /* -- Basic infrastructure -- */
  
      // Obtain maximum file component length from GetVolumeInformation which
--- 710,10 ---
< prev index next >