Class files are now added to the list file contents

This commit is contained in:
Szperak 2015-08-31 16:35:39 +02:00
parent 91f42e91d0
commit a0d552e573
2 changed files with 19 additions and 47 deletions

View File

@ -63,26 +63,28 @@ public class JarUtils {
try {
final String name = entry.getName();
final byte[] bytes = getBytes(jis);
if (!name.endsWith(".class")) {
if(!entry.isDirectory())
files.put(name, bytes);
} else {
String cafebabe = String.format("%02X", bytes[0])
+ String.format("%02X", bytes[1])
+ String.format("%02X", bytes[2])
+ String.format("%02X", bytes[3]);
if(cafebabe.toLowerCase().equals("cafebabe")) {
try {
final ClassNode cn = getNode(bytes);
container.classes.add(cn);
} catch(Exception e) {
e.printStackTrace();
}
if(!files.containsKey(name)){
if (!name.endsWith(".class")) {
if(!entry.isDirectory())
files.put(name, bytes);
} else {
System.out.println(jarFile+">"+name+": Header does not start with CAFEBABE, ignoring.");
String cafebabe = String.format("%02X", bytes[0])
+ String.format("%02X", bytes[1])
+ String.format("%02X", bytes[2])
+ String.format("%02X", bytes[3]);
if(cafebabe.toLowerCase().equals("cafebabe")) {
try {
final ClassNode cn = getNode(bytes);
container.classes.add(cn);
} catch(Exception e) {
e.printStackTrace();
}
} else {
System.out.println(jarFile+">"+name+": Header does not start with CAFEBABE, ignoring.");
}
files.put(name, bytes);
}
}
} catch(Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} finally {

View File

@ -311,36 +311,6 @@ public class FileNavigationPane extends VisibleComponent implements
ImageRenderer renderer = new ImageRenderer();
tree.setCellRenderer(renderer);
if(!container.classes.isEmpty()) {
for(ClassNode c : container.classes) {
String name = c.name;
final String[] spl = name.split("/");
if (spl.length < 2) {
root.add(new MyTreeNode(name+".class"));
} else {
MyTreeNode parent = root;
for (int i1 = 0; i1 < spl.length; i1++) {
String s = spl[i1];
MyTreeNode child = null;
for (int i = 0; i < parent.getChildCount(); i++) {
if (((MyTreeNode) parent.getChildAt(i)).getUserObject()
.equals(s)) {
child = (MyTreeNode) parent.getChildAt(i);
break;
}
}
if (child == null) {
if(i1 == spl.length-1)
child = new MyTreeNode(s+".class");
else
child = new MyTreeNode(s);
parent.add(child);
}
parent = child;
}
}
}
}
if(!container.files.isEmpty()) {
for (final Entry<String, byte[]> entry : container.files.entrySet()) {