import java.io.*; import java.util.*; import java.util.zip.*; /** * Outputs the versionCode and versionName of the APK files you input. * You can pass in -v or -d for verbose debugging information. */ public final class APK { private boolean v; public static void main(String[] args) { System.exit(new APK().realMain(args)); } public int realMain(String[] args) { int res = 0; List files = new ArrayList(); for (String arg : args) { if (arg.startsWith("-v") || arg.startsWith("-d")) { v = true; } else { files.add(arg); } } for (String fileName : files) { res |= read(fileName); } return res; } private final static class PackedInputStream { private final InputStream in; private int pos; PackedInputStream(InputStream in) { this.in = in; } public int pos() { return pos; } public int read() throws IOException { pos++; return 0xff & in.read(); } public int readBytes() throws IOException { int a = read() << 24; int b = read() << 16; int c = read() << 8; int d = read() << 0; return a + b + c + d; } public int readInt() throws IOException { int a = read() << 0; int b = read() << 8; int c = read() << 16; int d = read() << 24; return a + b + c + d; } public int readShort() throws IOException { int a = read() << 0; int b = read() << 8; return a + b; } public char readChar() throws IOException { int v = read(); read(); return (char)v; } public String readString() throws IOException { return readString(readShort()); } public String readString(int len) throws IOException { char[] arr = new char[len]; for (int i=0; i strings = new ArrayList(); for (int i=0; i