Few little tweaks to dev helpers
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@686621 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dacade8b45
commit
78907b6420
@ -45,37 +45,54 @@ public class POIFSLister {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < args.length; j++)
|
boolean withSizes = false;
|
||||||
{
|
for (int j = 0; j < args.length; j++) {
|
||||||
viewFile(args[ j ]);
|
if(args[j].equalsIgnoreCase("-size") ||
|
||||||
|
args[j].equalsIgnoreCase("-sizes")) {
|
||||||
|
withSizes = true;
|
||||||
|
} else {
|
||||||
|
viewFile(args[j], withSizes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void viewFile(final String filename) throws IOException
|
public static void viewFile(final String filename, boolean withSizes) throws IOException
|
||||||
{
|
{
|
||||||
POIFSFileSystem fs = new POIFSFileSystem(
|
POIFSFileSystem fs = new POIFSFileSystem(
|
||||||
new FileInputStream(filename)
|
new FileInputStream(filename)
|
||||||
);
|
);
|
||||||
displayDirectory(fs.getRoot(), "");
|
displayDirectory(fs.getRoot(), "", withSizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void displayDirectory(DirectoryNode dir, String indent) {
|
public static void displayDirectory(DirectoryNode dir, String indent, boolean withSizes) {
|
||||||
System.out.println(indent + dir.getName() + " -");
|
System.out.println(indent + dir.getName() + " -");
|
||||||
String newIndent = indent + " ";
|
String newIndent = indent + " ";
|
||||||
|
|
||||||
|
boolean hadChildren = false;
|
||||||
for(Iterator it = dir.getEntries(); it.hasNext(); ) {
|
for(Iterator it = dir.getEntries(); it.hasNext(); ) {
|
||||||
|
hadChildren = true;
|
||||||
Object entry = it.next();
|
Object entry = it.next();
|
||||||
if(entry instanceof DirectoryNode) {
|
if(entry instanceof DirectoryNode) {
|
||||||
displayDirectory((DirectoryNode)entry, newIndent);
|
displayDirectory((DirectoryNode)entry, newIndent, withSizes);
|
||||||
} else {
|
} else {
|
||||||
DocumentNode doc = (DocumentNode)entry;
|
DocumentNode doc = (DocumentNode)entry;
|
||||||
String name = doc.getName();
|
String name = doc.getName();
|
||||||
|
String size = "";
|
||||||
if(name.charAt(0) < 10) {
|
if(name.charAt(0) < 10) {
|
||||||
String altname = "(0x0" + (int)name.charAt(0) + ")" + name.substring(1);
|
String altname = "(0x0" + (int)name.charAt(0) + ")" + name.substring(1);
|
||||||
name = name.substring(1) + " <" + altname + ">";
|
name = name.substring(1) + " <" + altname + ">";
|
||||||
}
|
}
|
||||||
System.out.println(newIndent + name);
|
if(withSizes) {
|
||||||
}
|
size = " [" +
|
||||||
|
doc.getSize() + " / 0x" +
|
||||||
|
Integer.toHexString(doc.getSize()) +
|
||||||
|
"]";
|
||||||
|
}
|
||||||
|
System.out.println(newIndent + name + size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!hadChildren) {
|
||||||
|
System.out.println(newIndent + "(no children)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -66,12 +66,12 @@ public class HPBFDumper {
|
|||||||
dump.dumpContents();
|
dump.dumpContents();
|
||||||
dump.dumpEnvelope();
|
dump.dumpEnvelope();
|
||||||
dump.dumpEscher();
|
dump.dumpEscher();
|
||||||
|
dump.dump001CompObj(dump.fs.getRoot());
|
||||||
|
dump.dumpQuill();
|
||||||
|
|
||||||
// Still to go:
|
// Still to go:
|
||||||
// (0x03)Internal
|
// (0x03)Internal
|
||||||
// (0x01)CompObj
|
|
||||||
// Objects
|
// Objects
|
||||||
// Quill
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,5 +126,55 @@ public class HPBFDumper {
|
|||||||
|
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
System.out.println("Contents - " + data.length + " bytes long:");
|
System.out.println("Contents - " + data.length + " bytes long:");
|
||||||
|
|
||||||
|
// 8 bytes, always seems to be
|
||||||
|
// E8 AC 2C 00 E8 03 05 01
|
||||||
|
// E8 AC 2C 00 E8 03 05 01
|
||||||
|
|
||||||
|
// 4 bytes - size of contents
|
||||||
|
// 13/15 00 00 01
|
||||||
|
|
||||||
|
// ....
|
||||||
|
|
||||||
|
// E8 03 08 08 0C 20 03 00 00 00 00 88 16 00 00 00 ..... ..........
|
||||||
|
|
||||||
|
// 01 18 27 00 03 20 00 00 E8 03 08 08 0C 20 03 00 ..'.. ....... ..
|
||||||
|
|
||||||
|
// 01 18 30 00 03 20 00 00
|
||||||
|
// E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
|
||||||
|
// 00 00 00 88 1E 00 00 00
|
||||||
|
|
||||||
|
// 01 18 31 00 03 20 00 00
|
||||||
|
// E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
|
||||||
|
// 00 00 00 88 1E 00 00 00
|
||||||
|
|
||||||
|
// 01 18 32 00 03 20 00 00
|
||||||
|
// E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
|
||||||
|
// 00 00 00 88 1E 00 00 00
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dumpCONTENTS(DirectoryNode dir) throws IOException {
|
||||||
|
byte[] data = getData(dir, "CONTENTS");
|
||||||
|
|
||||||
|
System.out.println("");
|
||||||
|
System.out.println("CONTENTS - " + data.length + " bytes long:");
|
||||||
|
|
||||||
|
// Dump out up to 0x200
|
||||||
|
|
||||||
|
// Text from 0x200 onwards for a bit
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dump001CompObj(DirectoryNode dir) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dumpQuill() throws IOException {
|
||||||
|
DirectoryNode quillDir = (DirectoryNode)
|
||||||
|
fs.getRoot().getEntry("Quill");
|
||||||
|
DirectoryNode quillSubDir = (DirectoryNode)
|
||||||
|
quillDir.getEntry("QuillSub");
|
||||||
|
|
||||||
|
dump001CompObj(quillSubDir);
|
||||||
|
dumpCONTENTS(quillSubDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user