src/solaris/classes/sun/nio/fs/UnixSecureDirectoryStream.java

Print this page

        

@@ -38,11 +38,11 @@
 /**
  * Unix implementation of SecureDirectoryStream.
  */
 
 class UnixSecureDirectoryStream
-    extends SecureDirectoryStream<Path>
+    implements SecureDirectoryStream<Path>
 {
     private final UnixDirectoryStream ds;
     private final int dfd;
 
     UnixSecureDirectoryStream(UnixPath dir,

@@ -79,10 +79,24 @@
         if (!(obj instanceof UnixPath))
             throw new ProviderMismatchException();
         return (UnixPath)obj;
     }
 
+    private boolean followLinks(LinkOption... options) {
+        boolean followLinks = true;
+        for (LinkOption option: options) {
+            if (option == LinkOption.NOFOLLOW_LINKS) {
+                followLinks = false;
+                continue;
+            }
+            if (option == null)
+                throw new NullPointerException();
+            throw new AssertionError("Should not get here");
+        }
+        return followLinks;
+    }     
+
     /**
      * Opens sub-directory in this directory
      */
     @Override
     public SecureDirectoryStream<Path> newDirectoryStream(Path obj,

@@ -89,11 +103,11 @@
                                                           LinkOption... options)
         throws IOException
     {
         UnixPath file = getName(obj);
         UnixPath child = ds.directory().resolve(file);
-        boolean followLinks = file.getFileSystem().followLinks(options);
+        boolean followLinks = followLinks(options);
 
         // permission check using name resolved against original path of directory
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             child.checkRead();

@@ -300,11 +314,11 @@
     public <V extends FileAttributeView> V getFileAttributeView(Path obj,
                                                                 Class<V> type,
                                                                 LinkOption... options)
     {
         UnixPath file = getName(obj);
-        boolean followLinks = file.getFileSystem().followLinks(options);
+        boolean followLinks = followLinks(options);
         return getFileAttributeViewImpl(file, type, followLinks);
     }
 
     /**
      * A BasicFileAttributeView implementation that using a dfd/name pair.

@@ -334,13 +348,17 @@
         }
 
         private void checkWriteAccess() {
             SecurityManager sm = System.getSecurityManager();
             if (sm != null) {
+                if (file == null) {
+                    ds.directory().checkWrite();
+                } else {
                 ds.directory().resolve(file).checkWrite();
             }
         }
+        }
 
         @Override
         public String name() {
             return "basic";
         }