MCPcopy Create free account
hub / github.com/badvision/jace / main

Method main

src/main/java/jace/ConvertDiskImage.java:33–108  ·  view source on GitHub ↗
(String... args)

Source from the content-addressed store, hash-verified

31public class ConvertDiskImage {
32
33 public static void main(String... args) {
34 if (args.length != 2) {
35 showHelp();
36 return;
37 }
38 File in = new File(args[0]);
39 File out = new File(args[1]);
40 if (!in.exists()) {
41 showHelp();
42 System.out.println("Cannot find input file: " + args[0]);
43 return;
44 }
45 if (out.exists()) {
46 showHelp();
47 System.out.println("Output file already exists!: " + args[1]);
48 return;
49 }
50 String ext = args[1].substring(args[1].length() - 3);
51 boolean writeNibblized;
52 boolean writeProdosOrdered = false;
53 if (ext.equalsIgnoreCase("NIB")) {
54 System.out.println("Preparing to write NIB image");
55 writeNibblized = true;
56 } else if (ext.equalsIgnoreCase(".DO") || ext.equalsIgnoreCase("DSK")) {
57 System.out.println("Preparing to write DOS 3.3 ordered disk image");
58 writeNibblized = false;
59 writeProdosOrdered = false;
60 } else if (ext.equalsIgnoreCase(".PO")) {
61 System.out.println("Preparing to write Prodos ordered image");
62 writeNibblized = false;
63 writeProdosOrdered = true;
64 } else {
65 showHelp();
66 System.out.println("Could not understand desired output format");
67 return;
68 }
69
70 // First read in the disk image, this decodes the disk as necessary
71 FloppyDisk theDisk;
72 try {
73 theDisk = new FloppyDisk(in);
74 } catch (IOException ex) {
75 System.out.println("Couldn't read disk image");
76 return;
77 }
78 if (!writeNibblized) {
79 // Now change the disk image to point to a new file and adjust the sector ordering
80 System.out.println("Writing disk image with " + (writeProdosOrdered ? "prodos" : "dos 3.3") + " sector ordering");
81 theDisk.diskPath = out;
82 theDisk.isNibblizedImage = true;
83 theDisk.currentSectorOrder = writeProdosOrdered ? FloppyDisk.PRODOS_SECTOR_ORDER : FloppyDisk.DOS_33_SECTOR_ORDER;
84 theDisk.headerLength = 0;
85 for (int i = 0; i < FloppyDisk.TRACK_COUNT; i++) {
86 theDisk.updateTrack(i);
87 }
88 } else {
89 FileOutputStream fos = null;
90 System.out.println("Writing NIB image");

Callers

nothing calls this directly

Calls 4

showHelpMethod · 0.95
updateTrackMethod · 0.95
closeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected