From 0cc98012cdf703ee3a4e14e07c841e43bd99c56a Mon Sep 17 00:00:00 2001 From: Konloch Date: Sat, 26 Jun 2021 08:29:31 -0700 Subject: [PATCH] Fixed Directory Importing --- .../club/bytecodeviewer/BytecodeViewer.java | 1 - .../impl/DirectoryResourceImporter.java | 46 +++++++++++++++---- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index 4b483834..dada629e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -78,7 +78,6 @@ import static the.bytecode.club.bytecodeviewer.Constants.*; * + Synchronized scrolling is broken * + Spam-clicking the refresh button will cause the swing thread to deadlock (Quickly opening resources used to also do this) * This is caused by the ctrlMouseWheelZoom code, a temporary patch is just removing it worst case - * + Open as folder doesn't actually work * + Fix classfile searcher * + Smali Assembly compile - Needs to be fixed * + Krakatau Assembly compile - Needs to be fixed diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/DirectoryResourceImporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/DirectoryResourceImporter.java index a3f57cfb..656cce8b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/DirectoryResourceImporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/DirectoryResourceImporter.java @@ -1,6 +1,7 @@ package the.bytecode.club.bytecodeviewer.resources.importing.impl; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.resources.importing.ImportType; import the.bytecode.club.bytecodeviewer.resources.importing.Importer; import the.bytecode.club.bytecodeviewer.util.FileContainer; @@ -28,27 +29,52 @@ public class DirectoryResourceImporter implements Importer String dir = file.getAbsolutePath();//f.getAbsolutePath().substring(0, f.getAbsolutePath // ().length()-f.getName().length()); - while (!finished) { + while (!finished) + { boolean added = false; - for (int i = 0; i < totalFiles.size(); i++) { + for (int i = 0; i < totalFiles.size(); i++) + { File child = totalFiles.get(i); if (child.listFiles() != null) for (File rocket : Objects.requireNonNull(child.listFiles())) - if (!totalFiles.contains(rocket)) { + if (!totalFiles.contains(rocket)) + { totalFiles.add(rocket); added = true; } } - if (!added) { + if (!added) + { for (File child : totalFiles) - if (child.isFile()) { - String fileName = child.getAbsolutePath().substring(dir.length() + 1 - ).replaceAll("\\\\", "\\/"); - - - files1.put(fileName, Files.readAllBytes(Paths.get(child.getAbsolutePath()))); + { + if(!child.isFile()) + continue; + + final String trimmedPath = child.getAbsolutePath().substring(dir.length() + 1) + .replaceAll("\\\\", "\\/"); + final String fileName = child.getName(); + + //attempt to import archives automatically + if (fileName.endsWith(".jar") || fileName.endsWith(".zip") || fileName.endsWith(".war")) + { + ImportType.ZIP.getImporter().open(child); } + else if (fileName.endsWith(".apk")) + { + ImportType.APK.getImporter().open(child); + } + else if (fileName.endsWith(".dex")) + { + ImportType.DEX.getImporter().open(child); + } + else + { + //pack files into a single container + files1.put(trimmedPath, Files.readAllBytes(Paths.get(child.getAbsolutePath()))); + } + } + finished = true; } }