Preserve File Order

This commit is contained in:
Konloch 2021-07-11 01:50:12 -07:00
parent 2ef221f6e1
commit 845d9f253d
4 changed files with 15 additions and 15 deletions

View file

@ -14,6 +14,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Objects;
/**
@ -26,8 +27,8 @@ public class DirectoryResourceImporter implements Importer
public void open(File file) throws Exception
{
ResourceContainer container = new ResourceContainer(file);
HashMap<String, byte[]> allDirectoryFiles = new HashMap<>();
HashMap<String, ClassNode> allDirectoryClasses = new HashMap<>();
LinkedHashMap<String, byte[]> allDirectoryFiles = new LinkedHashMap<>();
LinkedHashMap<String, ClassNode> allDirectoryClasses = new LinkedHashMap<>();
boolean finished = false;
ArrayList<File> totalFiles = new ArrayList<>();

View file

@ -12,6 +12,7 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import java.io.*;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@ -30,7 +31,7 @@ public class XAPKResourceImporter implements Importer
public void open(File file) throws Exception
{
ResourceContainer container = new ResourceContainer(file);
HashMap<String, byte[]> allDirectoryFiles = new HashMap<>();
LinkedHashMap<String, byte[]> allDirectoryFiles = new LinkedHashMap<>();
Configuration.silenceExceptionGUI++; //turn exceptions off
try (ZipFile zipFile = new ZipFile(file))

View file

@ -5,10 +5,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.*;
import java.util.Map.Entry;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
@ -67,7 +64,7 @@ public class JarUtils
public static void importArchiveA(final File jarFile) throws IOException
{
ResourceContainer container = new ResourceContainer(jarFile);
HashMap<String, byte[]> files = new HashMap<>();
LinkedHashMap<String, byte[]> files = new LinkedHashMap<>();
ZipInputStream jis = new ZipInputStream(new FileInputStream(jarFile));
ZipEntry entry;
@ -121,7 +118,7 @@ public class JarUtils
// should also rebuild the archive byte offsets
ResourceContainer container = new ResourceContainer(jarFile);
HashMap<String, byte[]> files = new HashMap<>();
LinkedHashMap<String, byte[]> files = new LinkedHashMap<>();
try (ZipFile zipFile = new ZipFile(jarFile)) {
Enumeration<? extends ZipArchiveEntry> entries = zipFile.getEntries();
@ -196,11 +193,11 @@ public class JarUtils
* @param zipFile the input zip file
* @throws IOException
*/
public static HashMap<String, byte[]> loadResources(final File zipFile) throws IOException {
public static LinkedHashMap<String, byte[]> loadResources(final File zipFile) throws IOException {
if (!zipFile.exists())
return null; //just ignore
HashMap<String, byte[]> files = new HashMap<>();
LinkedHashMap<String, byte[]> files = new LinkedHashMap<>();
ZipInputStream jis = new ZipInputStream(new FileInputStream(zipFile));
ZipEntry entry;

View file

@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.util;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import org.apache.commons.io.FilenameUtils;
import org.objectweb.asm.tree.ClassNode;
@ -38,9 +39,9 @@ public class ResourceContainer
public String name;
public File APKToolContents = null;
public HashMap<String, byte[]> resourceFiles = new HashMap<>();
public HashMap<String, byte[]> resourceClassBytes = new HashMap<>();
public HashMap<String, ClassNode> resourceClasses = new HashMap<>();
public LinkedHashMap<String, byte[]> resourceFiles = new LinkedHashMap<>();
public LinkedHashMap<String, byte[]> resourceClassBytes = new LinkedHashMap<>();
public LinkedHashMap<String, ClassNode> resourceClasses = new LinkedHashMap<>();
public ResourceContainer(File f)
{