- removed the ability to dump to stdout (issues with the CLI recognizing '-' as a value instead of an option)

- tweaked the version and usage info

git-svn-id: https://smali.googlecode.com/svn/trunk@218 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-06-23 06:21:29 +00:00
parent 60188336df
commit c894b9658c
2 changed files with 21 additions and 31 deletions

View File

@ -38,11 +38,6 @@ public class dump {
public static void dump(DexFile dexFile, String dumpFileName, String outputDexFileName, boolean sort)
throws IOException {
boolean dumpToStdOut = false;
if (dumpFileName != null && dumpFileName.equals("-")) {
dumpToStdOut = true;
}
if (sort) {
//sort all items, to guarantee a unique ordering
dexFile.setSortAllItems(true);
@ -65,23 +60,20 @@ public class dump {
out.finishAnnotating();
FileWriter writer = null;
if (dumpToStdOut) {
out.writeAnnotationsTo(new OutputStreamWriter(System.out));
} else {
try {
writer = new FileWriter(dumpFileName);
out.writeAnnotationsTo(writer);
} catch (IOException ex) {
System.err.println("\n\nThere was an error while dumping the dex file to " + dumpFileName);
ex.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException ex) {
System.err.println("\n\nThere was an error while closing the dump file " + dumpFileName);
ex.printStackTrace();
}
try {
writer = new FileWriter(dumpFileName);
out.writeAnnotationsTo(writer);
} catch (IOException ex) {
System.err.println("\n\nThere was an error while dumping the dex file to " + dumpFileName);
ex.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException ex) {
System.err.println("\n\nThere was an error while closing the dump file " + dumpFileName);
ex.printStackTrace();
}
}
}

View File

@ -30,9 +30,10 @@ public class main {
public static final String VERSION = "0.91";
private static Options options;
private static final Options options;
static {
options = new Options();
buildOptions();
}
@ -161,16 +162,13 @@ public class main {
* Prints the version message.
*/
private static void version() {
System.out.println("baksmali " + VERSION);
System.out.println("baksmali " + VERSION + " (http://smali.googlecode.com)");
System.out.println("Copyright (C) 2009 Ben Gruver");
System.out.println("License: \"new\" BSD license");
System.out.println("http://smali.googlecode.com");
System.out.println("BSD license (http://www.opensource.org/licenses/bsd-license.php)");
System.exit(0);
}
private static void buildOptions() {
options = new Options();
Option versionOption = OptionBuilder.withLongOpt("version")
.withDescription("prints the version then exits")
.create("v");
@ -182,13 +180,13 @@ public class main {
Option dumpOption = OptionBuilder.withLongOpt("dump-to")
.withDescription("dumps the given dex file into a single annotated dump file named FILE (<dexfile>.dump by default), along with the normal disassembly.")
.hasOptionalArg()
.withArgName("FILE|-")
.withArgName("FILE")
.create("d");
Option dumpOnlyOption = OptionBuilder.withLongOpt("dump-only")
.withDescription("dumps the given dex file into a single annotated dump file named FILE (<dexfile>.dump by default), and does not generate the disassembly")
.hasOptionalArg()
.withArgName("FILE|-")
.withArgName("FILE")
.create("D");
Option writeDexOption = OptionBuilder.withLongOpt("write-dex")
@ -204,7 +202,7 @@ public class main {
.create("o");
Option sortOption = OptionBuilder.withLongOpt("sort")
.withDescription("when dumping or rewriting, sort the items in the dex file before dumping/writing.")
.withDescription("sort the items in the dex file into a canonical order before dumping/writing")
.create("s");
Option fixSignedRegisterOption = OptionBuilder.withLongOpt("fix-signed-registers")