diff --git a/src/com/webcodepro/applecommander/ui/UiBundle.properties b/src/com/webcodepro/applecommander/ui/UiBundle.properties index e5dc3b4..3e52a1f 100644 --- a/src/com/webcodepro/applecommander/ui/UiBundle.properties +++ b/src/com/webcodepro/applecommander/ui/UiBundle.properties @@ -102,7 +102,8 @@ CreateDirectoryMenuItem=Create Directory... CommandLineErrorMessage = Error: {0} CommandLineNoMatchMessage = {0}: No match. CommandLineStatus = {0} format; {1} bytes free; {2} bytes used. -CommandLineHelp = AppleCommander command line options [{0}]:\n-i [] display information about image(s).\n-ls [] list brief directory of image(s).\n-l [] list directory of image(s).\n-ll [] list detailed directory of image(s).\n-e export file from image to stdout.\n-x [] extract all files from image to directory.\n-g get raw file from image to stdout.\n-p [[$|0x]] put stdin\n in filename on image, using file type and address [0x2000].\n-d delete file from image.\n-k lock file on image.\n-u unlock file on image.\n-n change volume name (ProDOS or Pascal).\n-cc65 put stdin with cc65 header\n in filename on image, using file type and address from header.\n-geos interpret stdin as a GEOS conversion file and\n place it on image (ProDOS only).\n-dos140 create a 140K DOS 3.3 image.\n-pro140 create a 140K ProDOS image.\n-pro800 create an 800K ProDOS image.\n-pas140 create a 140K Pascal image.\n-pas800 create an 800K Pascal image. +CommandLineHelp = AppleCommander command line options [{0}]:\n-i [] display information about image(s).\n-ls [] list brief directory of image(s).\n-l [] list directory of image(s).\n-ll [] list detailed directory of image(s).\n-e export file from image to stdout.\n-x [] extract all files from image to directory.\n-g get raw file from image to stdout.\n-p [[$|0x]] put stdin\n in filename on image, using file type and address [0x2000].\n-d delete file from image.\n-k lock file on image.\n-u unlock file on image.\n-n change volume name (ProDOS or Pascal).\n-cc65 put stdin with cc65 header\n in filename on image, using file type and address from header.\n-geos interpret stdin as a GEOS conversion file and\n place it on image (ProDOS only).\n-dos140 create a 140K DOS 3.3 image.\n-pro140 create a 140K ProDOS image.\n-pro800 create an 800K ProDOS image.\n-pas140 create a 140K Pascal image.\n-pas800 create an 800K Pascal image.\n-unshrink uncompress a ShrinkIt disk image\n into a normal disk image. +CommandLineSDKReadOnly = SDK files are read-only # UserPreferences UserPreferencesComment = AppleCommander user preferences diff --git a/src/com/webcodepro/applecommander/ui/ac.java b/src/com/webcodepro/applecommander/ui/ac.java index c8b3293..4cd0e6d 100644 --- a/src/com/webcodepro/applecommander/ui/ac.java +++ b/src/com/webcodepro/applecommander/ui/ac.java @@ -77,6 +77,8 @@ import com.webcodepro.applecommander.util.TextBundle; * -pro800 <imagename> <volname> create an 800K ProDOS image. * -pas140 <imagename> <volname> create a 140K Pascal image. * -pas800 <imagename> <volname> create an 800K Pascal image. + * -unshrink <shrinksdk> <imagename> uncompress a ShrinkIt disk image + * into a normal disk image. * * * @author John B. Matthews @@ -127,6 +129,8 @@ public class ac { createProDisk(args[1], args[2], Disk.APPLE_140KB_DISK); } else if ("-pro800".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ createProDisk(args[1], args[2], Disk.APPLE_800KB_DISK); + } else if ("-unshrink".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ + unshrink(args[1], args[2]); } else { help(); } @@ -185,18 +189,22 @@ public class ac { buf.write(inb, 0, byteCount); } Disk disk = new Disk(imageName); - FormattedDisk[] formattedDisks = disk.getFormattedDisks(); - FormattedDisk formattedDisk = formattedDisks[0]; - FileEntry entry = name.createEntry(formattedDisk); - if (entry != null) { - entry.setFiletype(fileType); - entry.setFilename(name.name); - entry.setFileData(buf.toByteArray()); - if (entry.needsAddress()) { - entry.setAddress(stringToInt(address)); + if (!disk.isSDK()) { + FormattedDisk[] formattedDisks = disk.getFormattedDisks(); + FormattedDisk formattedDisk = formattedDisks[0]; + FileEntry entry = name.createEntry(formattedDisk); + if (entry != null) { + entry.setFiletype(fileType); + entry.setFilename(name.name); + entry.setFileData(buf.toByteArray()); + if (entry.needsAddress()) { + entry.setAddress(stringToInt(address)); + } + formattedDisk.save(); } - formattedDisk.save(); } + else + throw new IOException(textBundle.get("CommandLineSDKReadOnly")); } /** @@ -242,18 +250,22 @@ public class ac { static void deleteFile(String imageName, Name name) throws IOException { Disk disk = new Disk(imageName); - FormattedDisk[] formattedDisks = disk.getFormattedDisks(); - for (int i = 0; i < formattedDisks.length; i++) { - FormattedDisk formattedDisk = formattedDisks[i]; - FileEntry entry = name.getEntry(formattedDisk); - if (entry != null) { - entry.delete(); - disk.save(); - } else { - System.err.println(textBundle.format( - "CommandLineNoMatchMessage", name.fullName)); //$NON-NLS-1$ + if (!disk.isSDK()) { + FormattedDisk[] formattedDisks = disk.getFormattedDisks(); + for (int i = 0; i < formattedDisks.length; i++) { + FormattedDisk formattedDisk = formattedDisks[i]; + FileEntry entry = name.getEntry(formattedDisk); + if (entry != null) { + entry.delete(); + disk.save(); + } else { + System.err.println(textBundle.format( + "CommandLineNoMatchMessage", name.fullName)); //$NON-NLS-1$ + } } } + else + throw new IOException(textBundle.get("CommandLineSDKReadOnly")); } /** @@ -431,18 +443,22 @@ public class ac { static void setFileLocked(String imageName, Name name, boolean lockState) throws IOException { Disk disk = new Disk(imageName); - FormattedDisk[] formattedDisks = disk.getFormattedDisks(); - for (int i = 0; i < formattedDisks.length; i++) { - FormattedDisk formattedDisk = formattedDisks[i]; - FileEntry entry = name.getEntry(formattedDisk); - if (entry != null) { - entry.setLocked(lockState); - disk.save(); - } else { - System.err.println(textBundle.format( - "CommandLineNoMatchMessage", name.fullName)); //$NON-NLS-1$ + if (!disk.isSDK()) { + FormattedDisk[] formattedDisks = disk.getFormattedDisks(); + for (int i = 0; i < formattedDisks.length; i++) { + FormattedDisk formattedDisk = formattedDisks[i]; + FileEntry entry = name.getEntry(formattedDisk); + if (entry != null) { + entry.setLocked(lockState); + disk.save(); + } else { + System.err.println(textBundle.format( + "CommandLineNoMatchMessage", name.fullName)); //$NON-NLS-1$ + } } } + else + throw new IOException(textBundle.get("CommandLineSDKReadOnly")); } /** @@ -452,10 +468,14 @@ public class ac { public static void setDiskName(String imageName, String volName) throws IOException { Disk disk = new Disk(imageName); - FormattedDisk[] formattedDisks = disk.getFormattedDisks(); - FormattedDisk formattedDisk = formattedDisks[0]; - formattedDisk.setDiskName(volName); - formattedDisks[0].save(); + if (!disk.isSDK()) { + FormattedDisk[] formattedDisks = disk.getFormattedDisks(); + FormattedDisk formattedDisk = formattedDisks[0]; + formattedDisk.setDiskName(volName); + formattedDisks[0].save(); + } + else + throw new IOException(textBundle.get("CommandLineSDKReadOnly")); } /** @@ -491,6 +511,30 @@ public class ac { disks[0].save(); } + /** + * Unshrink the ShrinkIt data depending on what kind it is: + * + * SDK disk image - unpack it to a disk image + * ShrinkIt file bundle [future] - unpack files onto a disk image sized to fit + */ + static void unshrink(String shrinkName, String imageName) + throws IOException { + unshrink(shrinkName, imageName, 0); + } + + /** + * Unshrink the ShrinkIt data depending on what kind it is: + * + * SDK disk image - unpack it to a disk image + * ShrinkIt file bundle [future] - unpack files onto a disk image of reqeusted size + */ + static void unshrink(String shrinkName, String imageName, int imageSize) + throws IOException { + Disk disk = new Disk(shrinkName); + disk.setFilename(imageName); + disk.save(); + } + static int stringToInt(String s) { int i = 0; try {