Improved Directory Importing
This commit is contained in:
parent
c259ac70a2
commit
ad660815f3
3 changed files with 36 additions and 24 deletions
|
@ -10,6 +10,8 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public enum ResourceType
|
public enum ResourceType
|
||||||
{
|
{
|
||||||
|
//TODO tar/gzip?
|
||||||
|
|
||||||
CLASS_FILE(IconResources.classIcon, "class"),
|
CLASS_FILE(IconResources.classIcon, "class"),
|
||||||
JAVA_ARCHIVE(IconResources.jarIcon, "jar", "war", "ear"),
|
JAVA_ARCHIVE(IconResources.jarIcon, "jar", "war", "ear"),
|
||||||
ZIP_ARCHIVE(IconResources.zipIcon, "zip"),
|
ZIP_ARCHIVE(IconResources.zipIcon, "zip"),
|
||||||
|
|
|
@ -60,28 +60,12 @@ public class ImportResource implements Runnable
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check for zip archives
|
|
||||||
if (fn.endsWith(".jar") || fn.endsWith(".zip") || fn.endsWith(".war") || fn.endsWith(".ear"))
|
|
||||||
Import.ZIP.getImporter().open(file);
|
|
||||||
|
|
||||||
//check for classes
|
//check for classes
|
||||||
else if (fn.endsWith(".class"))
|
if (fn.endsWith(".class"))
|
||||||
Import.CLASS.getImporter().open(file);
|
Import.CLASS.getImporter().open(file);
|
||||||
|
|
||||||
//check for XAPKs
|
|
||||||
else if (fn.endsWith(".xapk"))
|
|
||||||
Import.XAPK.getImporter().open(file);
|
|
||||||
|
|
||||||
//check for APKs
|
|
||||||
else if (fn.endsWith(".apk"))
|
|
||||||
Import.APK.getImporter().open(file);
|
|
||||||
|
|
||||||
//check for DEX
|
|
||||||
else if (fn.endsWith(".dex"))
|
|
||||||
Import.DEX.getImporter().open(file);
|
|
||||||
|
|
||||||
//everything else import as a resource
|
//everything else import as a resource
|
||||||
else
|
else if(!importFile(file))
|
||||||
Import.FILE.getImporter().open(file);
|
Import.FILE.getImporter().open(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,4 +81,31 @@ public class ImportResource implements Runnable
|
||||||
} catch (NullPointerException ignored) { }
|
} catch (NullPointerException ignored) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean importFile(File file) throws Exception
|
||||||
|
{
|
||||||
|
final String fn = file.getName();
|
||||||
|
|
||||||
|
//check for zip archives
|
||||||
|
if (fn.endsWith(".jar") || fn.endsWith(".zip") || fn.endsWith(".war") || fn.endsWith(".ear"))
|
||||||
|
Import.ZIP.getImporter().open(file);
|
||||||
|
|
||||||
|
//check for XAPKs
|
||||||
|
else if (fn.endsWith(".xapk"))
|
||||||
|
Import.XAPK.getImporter().open(file);
|
||||||
|
|
||||||
|
//check for APKs
|
||||||
|
else if (fn.endsWith(".apk"))
|
||||||
|
Import.APK.getImporter().open(file);
|
||||||
|
|
||||||
|
//check for DEX
|
||||||
|
else if (fn.endsWith(".dex"))
|
||||||
|
Import.DEX.getImporter().open(file);
|
||||||
|
|
||||||
|
//return false
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.apache.commons.io.FilenameUtils;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.resources.importing.Import;
|
import the.bytecode.club.bytecodeviewer.resources.importing.Import;
|
||||||
|
import the.bytecode.club.bytecodeviewer.resources.importing.ImportResource;
|
||||||
import the.bytecode.club.bytecodeviewer.resources.importing.Importer;
|
import the.bytecode.club.bytecodeviewer.resources.importing.Importer;
|
||||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
||||||
|
@ -61,12 +62,10 @@ public class DirectoryResourceImporter implements Importer
|
||||||
final String fileName = child.getName();
|
final String fileName = child.getName();
|
||||||
|
|
||||||
//attempt to import archives automatically
|
//attempt to import archives automatically
|
||||||
if (fileName.endsWith(".jar") || fileName.endsWith(".zip") || fileName.endsWith(".war") || fileName.endsWith(".ear"))
|
if(ImportResource.importFile(file))
|
||||||
Import.ZIP.getImporter().open(child);
|
{
|
||||||
else if (fileName.endsWith(".apk"))
|
//let import resource handle it
|
||||||
Import.APK.getImporter().open(child);
|
}
|
||||||
else if (fileName.endsWith(".dex"))
|
|
||||||
Import.DEX.getImporter().open(child);
|
|
||||||
else if (fileName.endsWith(".class"))
|
else if (fileName.endsWith(".class"))
|
||||||
{
|
{
|
||||||
byte[] bytes = Files.readAllBytes(Paths.get(child.getAbsolutePath()));
|
byte[] bytes = Files.readAllBytes(Paths.get(child.getAbsolutePath()));
|
||||||
|
|
Loading…
Reference in a new issue