@NotNull private static File makeDirFromInput(JadxArgs args) { File outDir; String outDirName; File file = args.getInputFiles().get(0); String name = file.getName(); int pos = name.lastIndexOf('.'); if (pos != -1) { outDirName = name.substring(0, pos); } else { outDirName = name + "-" + JadxArgs.DEFAULT_OUT_DIR; } LOG.info("output directory: {}", outDirName); outDir = new File(outDirName); return outDir; }
private static void checkInputFiles(JadxArgs args) { List<File> inputFiles = args.getInputFiles(); if (inputFiles.isEmpty()) { throw new JadxArgsValidateException("Please specify input file"); } if (inputFiles.size() > 1) { for (File inputFile : inputFiles) { String fileName = inputFile.getName(); if (fileName.startsWith("--")) { throw new JadxArgsValidateException("Unknown argument: " + fileName); } } throw new JadxArgsValidateException("Only one input file supported"); } for (File file : inputFiles) { checkFile(file); } }
private JadxArgs makeArgs() { JadxArgs args = new JadxArgs(); args.getInputFiles().add(FileUtils.createTempFile("some.apk")); return args; } }
@Test public void checkNone() { setOutDirs(null, null, null); String inputFileBase = args.getInputFiles().get(0).getName().replace(".apk", ""); checkOutDirs(inputFileBase, inputFileBase + "/" + JadxArgs.DEFAULT_SRC_DIR, inputFileBase + "/" + JadxArgs.DEFAULT_RES_DIR); }
protected JadxArgs prepare(String inputFile) { JadxArgs args = new JadxArgs(); args.getInputFiles().add(new File(getSamplesDir(), inputFile)); args.setOutDir(new File("../jadx-external-tests-tmp")); return args; }
public void load() { reset(); JadxArgsValidator.validate(args); init(); LOG.info("loading ..."); loadFiles(args.getInputFiles()); root = new RootNode(args); root.load(inputFiles); root.initClassPath(); root.loadResources(getResources()); initVisitors(); }
@Test @Ignore public void testExampleUsage() { JadxArgs args = new JadxArgs(); args.getInputFiles().add(new File("test.apk")); args.setOutDir(new File("jadx-test-output")); JadxDecompiler jadx = new JadxDecompiler(args); jadx.load(); jadx.save(); }