Search in sources :

Example 1 with ClassDefItem

use of org.jf.dexlib.ClassDefItem in project otertool by wuntee.

the class SmaliWorkshop method getSmaliSource.

public static Map<String, File> getSmaliSource(File sourceSmaliOrDexFile, File destinationDirectory) throws IOException {
    Map<String, File> ret = new HashMap<String, File>();
    DexFile dexFile = new DexFile(sourceSmaliOrDexFile);
    IndentingWriter idWriter;
    for (ClassDefItem c : dexFile.ClassDefsSection.getItems()) {
        File classFile = SmaliWorkshop.createSmaliClassFile(destinationDirectory, c);
        String className = SmaliWorkshop.classDefItemToFilename(c);
        logger.debug("Got class: " + className + " [" + classFile + "]");
        BufferedWriter fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(classFile)));
        idWriter = new IndentingWriter(fileWriter);
        ClassDefinition cd = new ClassDefinition(c);
        cd.writeTo(idWriter);
        ret.put(className, classFile);
        idWriter.close();
    }
    return (sortMapByKey(ret));
}
Also used : ClassDefItem(org.jf.dexlib.ClassDefItem) HashMap(java.util.HashMap) FileOutputStream(java.io.FileOutputStream) IndentingWriter(org.jf.util.IndentingWriter) OutputStreamWriter(java.io.OutputStreamWriter) ClassDefinition(org.jf.baksmali.Adaptors.ClassDefinition) File(java.io.File) DexFile(org.jf.dexlib.DexFile) DexFile(org.jf.dexlib.DexFile) BufferedWriter(java.io.BufferedWriter)

Aggregations

BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 HashMap (java.util.HashMap)1 ClassDefinition (org.jf.baksmali.Adaptors.ClassDefinition)1 ClassDefItem (org.jf.dexlib.ClassDefItem)1 DexFile (org.jf.dexlib.DexFile)1 IndentingWriter (org.jf.util.IndentingWriter)1