Fixed Directory Importing

This commit is contained in:
Konloch 2021-06-26 08:29:31 -07:00
parent 166fe75b68
commit 0cc98012cd
2 changed files with 36 additions and 11 deletions

View file

@ -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

View file

@ -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("\\\\", "\\/");
{
if(!child.isFile())
continue;
final String trimmedPath = child.getAbsolutePath().substring(dir.length() + 1)
.replaceAll("\\\\", "\\/");
final String fileName = child.getName();
files1.put(fileName, Files.readAllBytes(Paths.get(child.getAbsolutePath())));
//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;
}
}