diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java index 30ea76e1..450cccdd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java @@ -72,7 +72,7 @@ public class FernFlowerDecompiler extends AbstractDecompiler @Override public String decompileClassNode(ClassNode cn, byte[] bytes) { - String start = TEMP_DIRECTORY + FS + MiscUtils.getUniqueName("", ".class"); + String start = TEMP_DIRECTORY + FS + MiscUtils.getUniqueNameBroken("", ".class"); final File tempClass = new File(start + ".class"); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JADXDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JADXDecompiler.java index 2fb464ea..6532ead4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JADXDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JADXDecompiler.java @@ -52,7 +52,7 @@ public class JADXDecompiler extends AbstractDecompiler String fileStart = TEMP_DIRECTORY + FS; String exception = ""; - final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class"); + final File tempClass = new File(MiscUtils.getUniqueNameBroken(fileStart, ".class") + ".class"); try (FileOutputStream fos = new FileOutputStream(tempClass)) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java index 199838c4..19e5318a 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java @@ -52,7 +52,7 @@ public class SmaliDisassembler extends AbstractDecompiler public String decompileClassNode(ClassNode cn, byte[] bytes) { final String fileStart = TEMP_DIRECTORY + FS + "temp"; - final String start = MiscUtils.getUniqueName(fileStart, ".class"); + final String start = MiscUtils.getUniqueNameBroken(fileStart, ".class"); final File tempClass = new File(start + ".class"); final File tempDex = new File(start + ".dex"); final File tempDexOut = new File(start + "-out"); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java index e4c4520d..116003c6 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java @@ -144,6 +144,36 @@ public class MiscUtils File tempFile; String randomString; + while (searching) + { + randomString = MiscUtils.randomString(32); + uniqueName = stringStart + randomString + fileExtension; + tempFile = new File(stringStart + randomString + fileExtension); + + if (!tempFile.exists()) + searching = false; + } + + return uniqueName; + } + + /** + * Checks the file system to ensure it's a unique name + * + * @param stringStart directory it'll be in + * @param fileExtension the file extension it'll use + * @return the unique name + */ + //TODO anything using this should be updated: + // The + ".class" needs to be removed + @Deprecated + public static String getUniqueNameBroken(String stringStart, String fileExtension) + { + String uniqueName = null; + boolean searching = true; + File tempFile; + String randomString; + while (searching) { randomString = MiscUtils.randomString(32);