Skip to content

Commit

Permalink
wip for expfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpaljak committed Mar 4, 2024
1 parent 09474a8 commit 956a7eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions task/src/main/java/pro/javacard/ant/DummyMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package pro.javacard.ant;

import pro.javacard.capfile.CAPFile;
import pro.javacard.sdk.ExportFileHelper;
import pro.javacard.sdk.JavaCardSDK;
import pro.javacard.sdk.OffCardVerifier;
import pro.javacard.sdk.VerifierError;
Expand All @@ -48,16 +49,22 @@ public static void main(String[] argv) {
System.exit(1);
} else if (args.size() == 1) {
final String capfile = args.remove(0);
if (Files.isRegularFile(Paths.get(capfile)) && capfile.endsWith(".cap")) {

Path path = Paths.get(capfile);
if (capfile.endsWith(".exp")) {
System.err.println("Expfile version: " + ExportFileHelper.getVersion(path));
System.exit(1);
}
if (Files.isRegularFile(path) && capfile.endsWith(".cap")) {
try {
CAPFile cap = CAPFile.fromBytes(Files.readAllBytes(Paths.get(capfile)));
CAPFile cap = CAPFile.fromBytes(Files.readAllBytes(path));
cap.dump(System.out);
} catch (Exception e) {
System.err.printf("Failed to read/parse CAP file: %s: %s%n", e.getClass().getSimpleName(), e.getMessage());
System.exit(1);
}
} else {
System.err.println("Usage: java -jar ant-javacard.jar <capfile>");
System.err.println("Usage: java -jar ant-javacard.jar <capfile|expfile>");
System.exit(1);
}
} else {
Expand Down

0 comments on commit 956a7eb

Please sign in to comment.