Fix getUniqueName
This commit is contained in:
parent
32b6f4ee8a
commit
8301a58db8
|
@ -72,7 +72,7 @@ public class FernFlowerDecompiler extends AbstractDecompiler
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
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");
|
final File tempClass = new File(start + ".class");
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class JADXDecompiler extends AbstractDecompiler
|
||||||
String fileStart = TEMP_DIRECTORY + FS;
|
String fileStart = TEMP_DIRECTORY + FS;
|
||||||
|
|
||||||
String exception = "";
|
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))
|
try (FileOutputStream fos = new FileOutputStream(tempClass))
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class SmaliDisassembler extends AbstractDecompiler
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||||
{
|
{
|
||||||
final String fileStart = TEMP_DIRECTORY + FS + "temp";
|
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 tempClass = new File(start + ".class");
|
||||||
final File tempDex = new File(start + ".dex");
|
final File tempDex = new File(start + ".dex");
|
||||||
final File tempDexOut = new File(start + "-out");
|
final File tempDexOut = new File(start + "-out");
|
||||||
|
|
|
@ -144,6 +144,36 @@ public class MiscUtils
|
||||||
File tempFile;
|
File tempFile;
|
||||||
String randomString;
|
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)
|
while (searching)
|
||||||
{
|
{
|
||||||
randomString = MiscUtils.randomString(32);
|
randomString = MiscUtils.randomString(32);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user