aboutsummaryrefslogtreecommitdiffstats
path: root/util/src
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-02-19 08:58:30 -0800
committerAndy Clement <aclement@pivotal.io>2019-02-19 08:58:30 -0800
commit044ddbb7f93e7234cc849e3092454e9f3d9ac3c3 (patch)
treea6638ae791c2a20adfb9516969de56b8e9a65d46 /util/src
parent9ae43a52cdf549a4c29f3c0c73b46918d5a76f8d (diff)
downloadaspectj-044ddbb7f93e7234cc849e3092454e9f3d9ac3c3.tar.gz
aspectj-044ddbb7f93e7234cc849e3092454e9f3d9ac3c3.zip
extra util for finding suitable files with mustBeJar option
Diffstat (limited to 'util/src')
-rw-r--r--util/src/main/java/org/aspectj/util/FileUtil.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/util/src/main/java/org/aspectj/util/FileUtil.java b/util/src/main/java/org/aspectj/util/FileUtil.java
index f3db2bda7..fef580e83 100644
--- a/util/src/main/java/org/aspectj/util/FileUtil.java
+++ b/util/src/main/java/org/aspectj/util/FileUtil.java
@@ -408,6 +408,41 @@ public class FileUtil {
return result;
}
+ public static File getBestFile(String[] paths, boolean mustBeJar) {
+ if (null == paths) {
+ return null;
+ }
+ File result = null;
+ for (int i = 0; (null == result) && (i < paths.length); i++) {
+ String path = paths[i];
+ if (null == path) {
+ continue;
+ }
+ if (path.startsWith("sp:")) {
+ try {
+ path = System.getProperty(path.substring(3));
+ } catch (Throwable t) {
+ path = null;
+ }
+ if (null == path) {
+ continue;
+ }
+ }
+ try {
+ File f = new File(path);
+
+ if (f.exists() && f.canRead()) {
+ if (mustBeJar && !f.isDirectory()) {
+ result = FileUtil.getBestFile(f);
+ }
+ }
+ } catch (Throwable t) {
+ // swallow
+ }
+ }
+ return result;
+ }
+
/**
* Render as best file, canonical or absolute.
*