do not list root files if possible in matcher
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Thu, 25 Aug 2011 09:54:48 +0000 (11:54 +0200)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Thu, 25 Aug 2011 09:54:48 +0000 (11:54 +0200)
nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/publish/fsScanner/RealRootDirectory.java

index e7dcd66effab4a739c709b8ba48f27bcb32b7ab1..ab28545c9c6bee33b4c7da66ce1b6b265eaa3e9e 100644 (file)
@@ -22,66 +22,62 @@ import java.io.File;
 import java.io.FileFilter;\r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.List;\r
 \r
-public class RealRootDirectory implements IDirectoryEntry\r
-  {\r
-    @NotNull\r
-    public String Name()\r
-    {\r
-      return "";\r
-    }\r
-\r
-    public IDirectoryEntry Parent()\r
-    {\r
-      return null;\r
-    }\r
+public class RealRootDirectory implements IDirectoryEntry {\r
+  @NotNull\r
+  public String Name() {\r
+    return "";\r
+  }\r
 \r
-    @NotNull\r
-    public IDirectoryEntry[] Subdirectories()\r
-    {\r
-      {\r
-        ArrayList<IDirectoryEntry> result = new ArrayList<IDirectoryEntry>();\r
-        if (SystemInfo.isWindows)\r
-        {          \r
-          for (File drive : File.listRoots())\r
-          {\r
-            result.add(new RealDirectoryEntry(new FileSystemPath(drive)));\r
-          }         \r
-        } else\r
-        {\r
-          for (File ch : new File("/").listFiles(new FileFilter() {\r
-            public boolean accept(File pathname) {\r
-              return pathname.isDirectory();\r
-            }\r
-          }))\r
-          {\r
-            result.add(new RealDirectoryEntry(new FileSystemPath(ch)));\r
-          }\r
-        }\r
+  public IDirectoryEntry Parent() {\r
+    return null;\r
+  }\r
 \r
-        return result.toArray(new IDirectoryEntry[result.size()]);\r
+  @NotNull\r
+  public IDirectoryEntry[] Subdirectories() {\r
+    ArrayList<IDirectoryEntry> result = new ArrayList<IDirectoryEntry>();\r
+    if (SystemInfo.isWindows) {\r
+      for (File drive : File.listRoots()) {\r
+        result.add(new RealDirectoryEntry(new FileSystemPath(drive)));\r
+      }\r
+    } else {\r
+      for (File ch : new File("/").listFiles(DIRECTORY_FILTER)) {\r
+        result.add(new RealDirectoryEntry(new FileSystemPath(ch)));\r
       }\r
     }\r
 \r
-    @NotNull\r
-    public IDirectoryEntry[] Subdirectories(Collection<String> names) {\r
-      return Subdirectories();\r
-    }\r
+    return result.toArray(new IDirectoryEntry[result.size()]);\r
+  }\r
 \r
-    @NotNull\r
-    public IFileEntry[] Files()\r
-    {\r
-      return new IFileEntry[0];\r
+  @NotNull\r
+  public IDirectoryEntry[] Subdirectories(Collection<String> names) {\r
+    List<IDirectoryEntry> entries = new ArrayList<IDirectoryEntry>(names.size());\r
+    for (String name : names) {\r
+      entries.add(new RealDirectoryEntry(new FileSystemPath(new File(SystemInfo.isWindows ? name : "/" + name))));\r
     }\r
+    return entries.toArray(new IDirectoryEntry[entries.size()]);\r
+  }\r
 \r
-    @NotNull\r
-    public IFileEntry[] Files(Collection<String> names) {\r
-      return new IFileEntry[0];\r
-    }\r
+  @NotNull\r
+  public IFileEntry[] Files() {\r
+    return new IFileEntry[0];\r
+  }\r
 \r
-    @Override\r
-    public String toString()\r
-    {\r
-      return "{d:FS_META_ROOT}";\r
-    }\r
+  @NotNull\r
+  public IFileEntry[] Files(Collection<String> names) {\r
+    return new IFileEntry[0];\r
+  }\r
+\r
+  @Override\r
+  public String toString() {\r
+    return "{d:FS_META_ROOT}";\r
   }\r
+\r
+  private final FileFilter DIRECTORY_FILTER = new FileFilter() {\r
+    public boolean accept(File pathname) {\r
+      return pathname.isDirectory();\r
+    }\r
+  };\r
+\r
+}\r