fix: resolve error if input file don't has extension
This commit is contained in:
@@ -23,6 +23,7 @@ import jadx.core.dex.nodes.DexNode;
|
||||
import jadx.core.dex.nodes.FieldNode;
|
||||
import jadx.core.dex.nodes.MethodNode;
|
||||
import jadx.core.dex.nodes.RootNode;
|
||||
import jadx.core.utils.files.FileUtils;
|
||||
import jadx.core.utils.files.InputFile;
|
||||
|
||||
public class RenameVisitor extends AbstractVisitor {
|
||||
@@ -35,9 +36,7 @@ public class RenameVisitor extends AbstractVisitor {
|
||||
}
|
||||
InputFile firstInputFile = dexNodes.get(0).getDexFile().getInputFile();
|
||||
Path inputFilePath = firstInputFile.getFile().getAbsoluteFile().toPath();
|
||||
|
||||
String inputName = inputFilePath.getFileName().toString();
|
||||
String baseName = inputName.substring(0, inputName.lastIndexOf('.'));
|
||||
String baseName = FileUtils.getPathBaseName(inputFilePath);
|
||||
Path deobfMapPath = inputFilePath.getParent().resolve(baseName + ".jobf");
|
||||
|
||||
JadxArgs args = root.getArgs();
|
||||
|
||||
@@ -232,6 +232,15 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPathBaseName(Path file) {
|
||||
String fileName = file.getFileName().toString();
|
||||
int extEndIndex = fileName.lastIndexOf('.');
|
||||
if (extEndIndex == -1) {
|
||||
return fileName;
|
||||
}
|
||||
return fileName.substring(0, extEndIndex);
|
||||
}
|
||||
|
||||
public static File toFile(String path) {
|
||||
if (path == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user