aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwisberg <wisberg>2004-10-06 10:27:23 +0000
committerwisberg <wisberg>2004-10-06 10:27:23 +0000
commit5e78267e4704582b80ea7da43cb77cc55d35175f (patch)
tree316a7927616475d3356e26b930857cdb894fa809
parent9faa21e85a0b33e45d8daa12ba75f50aabfb52ee (diff)
downloadaspectj-5e78267e4704582b80ea7da43cb77cc55d35175f.tar.gz
aspectj-5e78267e4704582b80ea7da43cb77cc55d35175f.zip
support for finding files at runtime, for javarun/aspectpath
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/Sandbox.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
index 0e1fe9737..2af724585 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
@@ -13,7 +13,10 @@
package org.aspectj.testing.harness.bridge;
import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
import java.util.ArrayList;
+import java.util.Arrays;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
@@ -327,6 +330,25 @@ public class Sandbox {
return testBaseSrcDir;
}
+ /**
+ * Get the files with names (case-sensitive)
+ * under the staging or test base directories.
+ * @param names
+ * @return
+ */
+ File[] findFiles(final String[] names) {
+ ArrayList result = new ArrayList();
+ NamesFilter filter = new NamesFilter(names);
+ File[] bases = { testBaseDir, sandboxDir };
+ for (int i = 0; i < bases.length; i++) {
+ File base = bases[i];
+ if ((null == base) || !base.canRead()) {
+ continue;
+ }
+ result.addAll(Arrays.asList(FileUtil.listFiles(base, filter)));
+ }
+ return (File[]) result.toArray(new File[0]);
+ }
File getTestBaseSrcDir(JavaRun caller) {
LangUtil.throwIaxIfNull(caller, "caller");
return testBaseSrcDir;
@@ -491,4 +513,23 @@ public class Sandbox {
LangUtil.throwIaxIfNull(caller, "caller");
return bootClasspath;
}
+ private static class NamesFilter implements FileFilter {
+ private final String[] names;
+ private NamesFilter(String[] names) {
+ this.names = names;
+ }
+ public boolean accept(File file) {
+ if (null != file) {
+ String name = file.getName();
+ if (null != name) {
+ for (int i = 0; i < names.length; i++) {
+ if (name.equals(names[i])) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+ }
}