changeset 7396:b94e612ae7c5

4792059: test/java/io/pathNames/GeneralSolaris.java fails on symbolic links Summary: Exclude the possible usage of linked files or directories in the test Reviewed-by: alanb
author igerasim
date Mon, 18 Aug 2014 17:18:23 +0400
parents 74c83f186ab1
children 8a39734cca39
files test/java/io/pathNames/General.java
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/io/pathNames/General.java	Mon Aug 18 17:16:50 2014 +0400
+++ b/test/java/io/pathNames/General.java	Mon Aug 18 17:18:23 2014 +0400
@@ -28,6 +28,7 @@
 
 import java.io.*;
 import java.util.*;
+import java.nio.file.*;
 
 
 public class General {
@@ -57,7 +58,7 @@
         for (int i = 0; i < dl.length; i++) {
             File f = new File(subdir, dl[i]);
             File df = new File(dir, f.getPath());
-            if (df.exists() && df.isFile()) {
+            if (Files.isRegularFile(df.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                 return f.getPath();
             }
         }
@@ -65,7 +66,7 @@
             File f = (subdir.length() == 0) ? new File(dl[i])
                                             : new File(subdir, dl[i]);
             File df = new File(dir, f.getPath());
-            if (df.exists() && df.isDirectory()) {
+            if (Files.isDirectory(df.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                 String[] dl2 = df.list();
                 if (dl2 != null) {
                     String ff = findSomeFile(dir, f.getPath(), dl2);
@@ -90,7 +91,7 @@
         }
         for (int i = 0; i < dl.length; i++) {
             File f = new File(dir, dl[i]);
-            if (f.isFile()) {
+            if (Files.isRegularFile(f.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                 return dl[i];
             }
         }
@@ -127,7 +128,7 @@
         }
         for (int i = 0; i < dl.length; i++) {
             File f = new File(d, dl[i]);
-            if (f.isDirectory()) {
+            if (Files.isDirectory(f.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                 String[] dl2 = f.list();
                 if (dl2 == null || dl2.length >= 250) {
                     /* Heuristic to avoid scanning huge directories */
@@ -314,7 +315,7 @@
 
         /* Normal name */
         if (f.exists()) {
-            if (f.isDirectory() && f.list() != null) {
+            if (Files.isDirectory(f.toPath(), LinkOption.NOFOLLOW_LINKS) && f.list() != null) {
                 if ((n = findSomeFile(ans, create)) != null)
                     checkSlashes(d, create, ans + n, ask + n);
                 if ((n = findSomeDir(ans, create)) != null)