diff options
author | aclement <aclement> | 2006-05-04 07:14:47 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-05-04 07:14:47 +0000 |
commit | 5a01932b9dbdf81fe41e029fa56ede17364a2c2e (patch) | |
tree | a2991f73f2b496670e3de21f00538fbae9da891d /util | |
parent | cb5dfe759852d4965c692934ed7e14c41f61b715 (diff) | |
download | aspectj-5a01932b9dbdf81fe41e029fa56ede17364a2c2e.tar.gz aspectj-5a01932b9dbdf81fe41e029fa56ede17364a2c2e.zip |
fixes for 137235 (contributed by Ron): more intelligent logic for determining if a path entry is a jar/zip (don't just rely on suffix, some new .bndl files seem to be becoming popular...)
Diffstat (limited to 'util')
-rw-r--r-- | util/src/org/aspectj/util/FileUtil.java | 19 | ||||
-rw-r--r-- | util/src/org/aspectj/util/Reflection.java | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/util/src/org/aspectj/util/FileUtil.java b/util/src/org/aspectj/util/FileUtil.java index a0f0a9021..b3fb3742d 100644 --- a/util/src/org/aspectj/util/FileUtil.java +++ b/util/src/org/aspectj/util/FileUtil.java @@ -17,7 +17,6 @@ import java.io.*; import java.net.*; import java.util.*; import java.util.zip.*; -import java.util.zip.ZipFile; /** @@ -33,7 +32,7 @@ public class FileUtil { public static final FileFilter ZIP_FILTER = new FileFilter() { public boolean accept(File file) { - return hasZipSuffix(file); + return isZipFile(file); } public String toString() { return "ZIP_FILTER"; @@ -70,15 +69,19 @@ public class FileUtil { PERMIT_CVS = LangUtil.getBoolean(name, false); } - /** @return true if file path has a zip/jar suffix */ - public static boolean hasZipSuffix(File file) { - return ((null != file) && hasZipSuffix(file.getPath())); + /** @return true if file exists and is a zip file */ + public static boolean isZipFile(File file) { + try { + return (null != file) && new ZipFile(file) != null; + } catch (IOException e) { + return false; + } } /** @return true if path ends with .zip or .jar */ - public static boolean hasZipSuffix(String path) { - return ((null != path) && (0 != zipSuffixLength(path))); - } +// public static boolean hasZipSuffix(String path) { +// return ((null != path) && (0 != zipSuffixLength(path))); +// } /** @return 0 if file has no zip/jar suffix or 4 otherwise */ public static int zipSuffixLength(File file) { diff --git a/util/src/org/aspectj/util/Reflection.java b/util/src/org/aspectj/util/Reflection.java index 10bcc1583..3610eb7f4 100644 --- a/util/src/org/aspectj/util/Reflection.java +++ b/util/src/org/aspectj/util/Reflection.java @@ -136,7 +136,7 @@ public class Reflection { // if (!file.canRead()) { // throw new IllegalArgumentException("cannot read " + file); // } - if (FileUtil.hasZipSuffix(file)) { + if (FileUtil.isZipFile(file)) { libs.add(file); } else if (file.isDirectory()) { dirs.add(file); |