提交 600842a1 编写于 作者: S Skylot

fix: resolve error if input file don't has extension

上级 8ba3e935
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册