summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authoraclement <aclement>2006-05-04 07:14:47 +0000
committeraclement <aclement>2006-05-04 07:14:47 +0000
commit5a01932b9dbdf81fe41e029fa56ede17364a2c2e (patch)
treea2991f73f2b496670e3de21f00538fbae9da891d /util
parentcb5dfe759852d4965c692934ed7e14c41f61b715 (diff)
downloadaspectj-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.java19
-rw-r--r--util/src/org/aspectj/util/Reflection.java2
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);