*/
public List<UnwovenClassFile> addJarFile(File inFile, File outDir, boolean canBeDirectory) {
// System.err.println("? addJarFile(" + inFile + ", " + outDir + ")");
List<UnwovenClassFile> addedClassFiles = new ArrayList<UnwovenClassFile>();
needToReweaveWorld = true;
JarFile inJar = null;
try {
// Is this a directory we are looking at?
if (inFile.isDirectory() && canBeDirectory) {
addedClassFiles.addAll(addDirectoryContents(inFile, outDir));
} else {
inJar = new JarFile(inFile);
try {
addManifest(inJar.getManifest());
Enumeration entries = inJar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = (JarEntry) entries.nextElement();
InputStream inStream = inJar.getInputStream(entry);
byte[] bytes = FileUtil.readAsByteArray(inStream);
String filename = entry.getName();
// System.out.println("? addJarFile() filename='" + filename
// + "'");
UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes);
if (filename.endsWith(".class")) {
ReferenceType type = this.addClassFile(classFile, false);
StringBuffer sb = new StringBuffer();
sb.append(inFile.getAbsolutePath());
sb.append("!");
sb.append(entry.getName());
type.setBinaryPath(sb.toString());
addedClassFiles.add(classFile);
}
// else if (!entry.isDirectory()) {
//
// /* bug-44190 Copy meta-data */
// addResource(filename,classFile);
// }
inStream.close();
}
} finally {
inJar.close();
}
inJar.close();
}
} catch (FileNotFoundException ex) {
IMessage message = new Message("Could not find input jar file " + inFile.getPath() + ", ignoring", new SourceLocation(
inFile, 0), false);
world.getMessageHandler().handleMessage(message);
} catch (IOException ex) {
IMessage message = new Message("Could not read input jar file " + inFile.getPath() + "(" + ex.getMessage() + ")",
new SourceLocation(inFile, 0), true);
world.getMessageHandler().handleMessage(message);
} finally {
if (inJar != null) {
try {
inJar.close();
} catch (IOException ex) {
IMessage message = new Message("Could not close input jar file " + inFile.getPath() + "(" + ex.getMessage()
+ ")", new SourceLocation(inFile, 0), true);
world.getMessageHandler().handleMessage(message);
}