From f9c9588f1dc97127898cf3e1de60e65e257a2e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Wi=C5=9Bniewski?= Date: Tue, 27 Apr 2010 21:29:49 +0200 Subject: [PATCH] DexFileBuilder: added possibility to name streams. --- src/brut/androlib/util/DexFileBuilder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/brut/androlib/util/DexFileBuilder.java b/src/brut/androlib/util/DexFileBuilder.java index 0900c95b..c4a5e95e 100644 --- a/src/brut/androlib/util/DexFileBuilder.java +++ b/src/brut/androlib/util/DexFileBuilder.java @@ -32,15 +32,17 @@ import org.jf.smali.*; public class DexFileBuilder { public void addSmaliFile(File smaliFile) throws AndrolibException { try { - addSmaliFile(new FileInputStream(smaliFile)); + addSmaliFile(new FileInputStream(smaliFile), + smaliFile.getAbsolutePath()); } catch (FileNotFoundException ex) { throw new AndrolibException(ex); } } - public void addSmaliFile(InputStream smaliStream) throws AndrolibException { + public void addSmaliFile(InputStream smaliStream, String name) + throws AndrolibException { try { - if (!assembleSmaliFile(smaliStream)) { + if (!assembleSmaliFile(smaliStream, name)) { throw new AndrolibException( "Could not smali file: " + smaliStream); } @@ -80,9 +82,10 @@ public class DexFileBuilder { return bytes; } - private boolean assembleSmaliFile(InputStream smaliStream) + private boolean assembleSmaliFile(InputStream smaliStream, String name) throws IOException, RecognitionException { ANTLRInputStream input = new ANTLRInputStream(smaliStream, "UTF8"); + input.name = name; smaliLexer lexer = new smaliLexer(input);