Skip to content

Commit

Permalink
fix: resolve error if input file don't has extension
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Nov 30, 2019
1 parent 8ba3e93 commit 600842a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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 {
Expand All @@ -35,9 +36,7 @@ public void init(RootNode root) {
}
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();
Expand Down
9 changes: 9 additions & 0 deletions jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ private static boolean isZipFileCanBeOpen(File file) {
}
}

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;
Expand Down

0 comments on commit 600842a

Please sign in to comment.