diff options
Diffstat (limited to 'util/src')
-rw-r--r-- | util/src/main/java/org/aspectj/util/FileUtil.java | 35 |
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. * |