Rename the option to unpack shrinkit to reflect the more general nature of DC42

Make all Shrinkit and DC42 images read-only from the command line
This commit is contained in:
2012-08-02 03:18:07 +00:00
parent efa325f75d
commit 8276bbd8c3
5 changed files with 61 additions and 39 deletions

View File

@ -41,9 +41,9 @@
<!-- Now, copy a file to the images -->
<appleCommander command="p" input="manifest.mf" imagename="${dos140image}" filename="MANIFEST" type="T" />
<appleCommander command="p" input="manifest.mf" imagename="${pas140image}" filename="MANIFEST" type="text" />
<appleCommander command="p" input="manifest.mf" imagename="${pas800image}" filename="MANIFEST" type="text" />
<appleCommander command="p" input="manifest.mf" failonerror="false" imagename="${pas800image}" filename="MANIFEST" type="text" />
<appleCommander command="p" input="manifest.mf" imagename="${pro140image}" filename="MANIFEST" type="txt" />
<appleCommander command="p" input="${pas140image}" imagename="${pro800image}" filename="BIG140IMG" type="bin" />
<appleCommander command="p" input="${pas140image}" failonerror="false" imagename="${pro800image}" filename="BIG140IMG" type="bin" />
<!-- Now, copy a file that should not fit on the images -->
<echo message="Here we expect messages from [appleCommander] complaining about file space requirements not being met..."/>
<appleCommander failonerror="false" command="p" input="${pro800image}" imagename="${dos140image}" filename="BLOWUP" type="T" />
@ -81,10 +81,8 @@
<appleCommander command="g" imagename="${pro140image}" filename="TEST" />
<appleCommander command="x" imagename="${pro140image}" outputpath="${projdir}/work/dist" />
<echo message="Files should be exported to the current working directory now." />
<!-- Now, try out unshrinking -->
<!--
<appleCommander command="unshrink" filename="DiskCommander.GS.sdk" imagename="${projdir}/work/dist/test.po" />
-->
<!-- Now, try out converting -->
<appleCommander command="convert" filename="C:\David\Asimov\images\gs\utils\DiskCommander.GS.sdk" imagename="${projdir}/work/dist/test.po" />
</target>
<target name="clean" description="Get rid of testing artifacts.">

View File

@ -94,6 +94,7 @@ public class Disk {
private TextBundle textBundle = StorageBundle.getInstance();
private String filename;
private boolean newImage = false;
private boolean isDC42 = false;
private ByteArrayImageLayout diskImageManager;
private ImageOrder imageOrder = null;
@ -196,15 +197,13 @@ public class Disk {
diskImage = diskImageByteArray.toByteArray();
}
int offset = 0;
boolean is2img = false, isDC42 = false;
boolean is2img = false;
/* Does it have the 2IMG header? */
if ((diskImage[00] == 0x32) && (diskImage[01] == 0x49) && (diskImage[02] == 0x4D) && (diskImage[03]) == 0x47) {
if ((diskImage[0] == 0x32) && (diskImage[1] == 0x49) && (diskImage[2] == 0x4D) && (diskImage[3]) == 0x47) {
is2img = true;
offset = UniversalDiskImageLayout.OFFSET;
}
/* Does it have the DiskCopy 4.2 header? */
else if (((diskImage[0x52] == 0x01) && (diskImage[0x53] == 0x00)) &&
((diskImage[0x51] == 0x02) || (diskImage[0x51] == 0x22) || (diskImage[0x51] == 0x24))) {
else if (Disk.isDC42(diskImage)) {
isDC42 = true;
offset = 84;
long end = AppleUtil.getLongValue(diskImage,0x40);
@ -214,9 +213,13 @@ public class Disk {
diskImageManager = new ByteArrayImageLayout(diskImageDC42);
}
else
throw new IllegalArgumentException(textBundle.get("Disk.ResizeDiskError")); // FIXME - need a better explanation of this
throw new IllegalArgumentException(textBundle.get("CommandLineDC42Bad")); //$NON-NLS-1$
}
if (is2img == true || diskImage.length == APPLE_800KB_DISK + offset || diskImage.length == APPLE_5MB_HARDDISK + offset || diskImage.length == APPLE_10MB_HARDDISK + offset || diskImage.length == APPLE_20MB_HARDDISK + offset || diskImage.length == APPLE_32MB_HARDDISK + offset) {
if (is2img == true || diskImage.length == APPLE_800KB_DISK + UniversalDiskImageLayout.OFFSET
|| diskImage.length == APPLE_5MB_HARDDISK + UniversalDiskImageLayout.OFFSET
|| diskImage.length == APPLE_10MB_HARDDISK + UniversalDiskImageLayout.OFFSET
|| diskImage.length == APPLE_20MB_HARDDISK + UniversalDiskImageLayout.OFFSET
|| diskImage.length == APPLE_32MB_HARDDISK + UniversalDiskImageLayout.OFFSET) {
diskImageManager = new UniversalDiskImageLayout(diskImage);
} else if (isDC42) {
diskImageManager = new ByteArrayImageLayout(diskImageDC42);
@ -360,8 +363,8 @@ public class Disk {
}
/**
* Returns the diskImage.
* @return byte[]
* Returns the diskImageManager.
* @return ByteArrayImageLayout diskImageManager The disk Image Manager of this disk
*/
public ByteArrayImageLayout getDiskImageManager() {
if (imageOrder != null) {
@ -748,7 +751,21 @@ public class Disk {
&& vtoc[0x01] == 7 // expect catalog to start on sector 7
&& vtoc[0x0f] == -115; // expect 0x8d's every 16 bytes
}
/**
* Indicates if a given byte sequence is likely to be a DiskCopy 42 stream.
*
* @return boolean liklihood it is a DC42 stream
*/
private static boolean isDC42(byte[] buffer) {
boolean truth = ((buffer[0x52] == 0x01) && (buffer[0x53] == 0x00)) &&
((buffer[0x51] == 0x02) || (buffer[0x51] == 0x22) || (buffer[0x51] == 0x24));
return (((buffer[0x52] == 0x01) && (buffer[0x53] == 0x00)) &&
((buffer[0x51] == 0x02) || (buffer[0x51] == 0x22) || (buffer[0x51] == 0x24)));
}
public boolean isDC42() {
return isDC42;
}
/**
* Indicates if the disk has changed. Triggered when data is
* written and cleared when data is saved.
@ -766,7 +783,7 @@ public class Disk {
}
/**
* Answer with the phyiscal ordering of the disk.
* Answer with the physical ordering of the disk.
*/
public ImageOrder getImageOrder() {
return imageOrder;

View File

@ -45,7 +45,7 @@ public class AntTask extends Task
* dos140: <imagename> <volname>
* pro140/pro800: <imagename> <volname>
* pas140/pas800: <imagename> <volname>
* unshrink: <filename> <imagename>
* convert: <filename> <imagename>
*/
if (_command.equals("i"))
{
@ -81,7 +81,9 @@ public class AntTask extends Task
try
{
if (_command.equals("p"))
{
com.webcodepro.applecommander.ui.ac.putFile(_input, _imageName, _fileName, _type, _address);
}
else
com.webcodepro.applecommander.ui.ac.putCC65(_input, _imageName, _fileName, _type);
}
@ -220,11 +222,11 @@ public class AntTask extends Task
System.out.println(io.getMessage());
}
}
else if (_command.equals("unshrink"))
else if (_command.equals("convert"))
{
try
{
com.webcodepro.applecommander.ui.ac.unshrink(_fileName, _imageName);
com.webcodepro.applecommander.ui.ac.convert(_fileName, _imageName);
}
catch (IOException io)
{

View File

@ -102,8 +102,9 @@ 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 <imagename> [<imagename>] display information about image(s).\n-ls <imagename> [<imagename>] list brief directory of image(s).\n-l <imagename> [<imagename>] list directory of image(s).\n-ll <imagename> [<imagename>] list detailed directory of image(s).\n-e <imagename> <filename> export file from image to stdout.\n-x <imagename> [<directory>] extract all files from image to directory.\n-g <imagename> <filename> get raw file from image to stdout.\n-p <imagename> <filename> <type> [[$|0x]<addr>] put stdin\n in filename on image, using file type and address [0x2000].\n-d <imagename> <filename> delete file from image.\n-k <imagename> <filename> lock file on image.\n-u <imagename> <filename> unlock file on image.\n-n <imagename> <volname> change volume name (ProDOS or Pascal).\n-cc65 <imagename> <filename> <type> put stdin with cc65 header\n in filename on image, using file type and address from header.\n-geos <imagename> interpret stdin as a GEOS conversion file and\n place it on image (ProDOS only).\n-dos140 <imagename> create a 140K DOS 3.3 image.\n-pro140 <imagename> <volname> create a 140K ProDOS image.\n-pro800 <imagename> <volname> create an 800K ProDOS image.\n-pas140 <imagename> <volname> create a 140K Pascal image.\n-pas800 <imagename> <volname> create an 800K Pascal image.\n-unshrink <shrinksdk> <imagename> uncompress a ShrinkIt disk image\n into a normal disk image.
CommandLineSDKReadOnly = SDK files are read-only
CommandLineHelp = AppleCommander command line options [{0}]:\n-i <imagename> [<imagename>] display information about image(s).\n-ls <imagename> [<imagename>] list brief directory of image(s).\n-l <imagename> [<imagename>] list directory of image(s).\n-ll <imagename> [<imagename>] list detailed directory of image(s).\n-e <imagename> <filename> export file from image to stdout.\n-x <imagename> [<directory>] extract all files from image to directory.\n-g <imagename> <filename> get raw file from image to stdout.\n-p <imagename> <filename> <type> [[$|0x]<addr>] put stdin\n in filename on image, using file type and address [0x2000].\n-d <imagename> <filename> delete file from image.\n-k <imagename> <filename> lock file on image.\n-u <imagename> <filename> unlock file on image.\n-n <imagename> <volname> change volume name (ProDOS or Pascal).\n-cc65 <imagename> <filename> <type> put stdin with cc65 header\n in filename on image, using file type and address from header.\n-geos <imagename> interpret stdin as a GEOS conversion file and\n place it on image (ProDOS only).\n-dos140 <imagename> create a 140K DOS 3.3 image.\n-pro140 <imagename> <volname> create a 140K ProDOS image.\n-pro800 <imagename> <volname> create an 800K ProDOS image.\n-pas140 <imagename> <volname> create a 140K Pascal image.\n-pas800 <imagename> <volname> create an 800K Pascal image.\n-convert <filename> <imagename> uncompress a ShrinkIt file or disk image\n or convert a DiskCopy 4.2 image into a ProDOS disk image.
CommandLineSDKReadOnly = SDK, SHK, and DC42 files are read-only. Use the convert option on them first.
CommandLineDC42Bad = Unable to interpret this DiskCopy 42 image.
# UserPreferences
UserPreferencesComment = AppleCommander user preferences

View File

@ -77,8 +77,8 @@ import com.webcodepro.applecommander.util.TextBundle;
* -pro800 &lt;imagename&gt; &lt;volname&gt; create an 800K ProDOS image.
* -pas140 &lt;imagename&gt; &lt;volname&gt; create a 140K Pascal image.
* -pas800 &lt;imagename&gt; &lt;volname&gt; create an 800K Pascal image.
* -unshrink &lt;shrinksdk&gt; &lt;imagename&gt; uncompress a ShrinkIt disk image
* into a normal disk image.
* -convert &lt;filename&gt; &lt;imagename&gt; uncompress a ShrinkIt file or disk image
* or convert a DiskCopy 4.2 image into a ProDOS disk image.
* </pre>
*
* @author John B. Matthews
@ -129,8 +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 if ("-convert".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
convert(args[1], args[2]);
} else {
help();
}
@ -176,7 +176,7 @@ public class ac {
}
/**
* Put &lt;stdin> into the file named fileName on the disk named imageName;
* Put &lt;stdin&gt. into the file named fileName on the disk named imageName;
* Note: only volume level supported; input size unlimited.
*/
static void putFile(String imageName, Name name, String fileType,
@ -189,9 +189,11 @@ public class ac {
buf.write(inb, 0, byteCount);
}
Disk disk = new Disk(imageName);
if (!disk.isSDK()) {
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
FormattedDisk formattedDisk = formattedDisks[0];
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
if (formattedDisks == null)
System.out.println("Dude, formattedDisks is null!");
FormattedDisk formattedDisk = formattedDisks[0];
if (!disk.isSDK() && !disk.isDC42()) {
FileEntry entry = name.createEntry(formattedDisk);
if (entry != null) {
entry.setFiletype(fileType);
@ -251,7 +253,7 @@ public class ac {
throws IOException {
Disk disk = new Disk(imageName);
Name name = new Name(fileName);
if (!disk.isSDK()) {
if (!disk.isSDK() && !disk.isDC42()) {
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
for (int i = 0; i < formattedDisks.length; i++) {
FormattedDisk formattedDisk = formattedDisks[i];
@ -456,7 +458,7 @@ public class ac {
static void setFileLocked(String imageName, Name name,
boolean lockState) throws IOException {
Disk disk = new Disk(imageName);
if (!disk.isSDK()) {
if (!disk.isSDK() && !disk.isDC42()) {
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
for (int i = 0; i < formattedDisks.length; i++) {
FormattedDisk formattedDisk = formattedDisks[i];
@ -481,7 +483,7 @@ public class ac {
public static void setDiskName(String imageName, String volName)
throws IOException {
Disk disk = new Disk(imageName);
if (!disk.isSDK()) {
if (!disk.isSDK() && !disk.isDC42()) {
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
FormattedDisk formattedDisk = formattedDisks[0];
formattedDisk.setDiskName(volName);
@ -525,23 +527,25 @@ public class ac {
}
/**
* Unshrink the ShrinkIt data depending on what kind it is:
* Unshrink or otherwise interpret incoming data depending on what kind it is:
*
* DiskCopy 4.2 image - convert it to a ProDOS image
* 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)
static void convert(String shrinkName, String imageName)
throws IOException {
unshrink(shrinkName, imageName, 0);
convert(shrinkName, imageName, 0);
}
/**
* Unshrink the ShrinkIt data depending on what kind it is:
* Unshrink or otherwise interpret incoming data depending on what kind it is:
*
* DiskCopy 4.2 image - convert it to a ProDOS image
* SDK disk image - unpack it to a disk image
* ShrinkIt file bundle [future] - unpack files onto a disk image of requested size
* ShrinkIt file bundle [future] - unpack files onto a disk image sized to fit
*/
static void unshrink(String shrinkName, String imageName, int imageSize)
static void convert(String shrinkName, String imageName, int imageSize)
throws IOException {
Disk disk = new Disk(shrinkName);
disk.setFilename(imageName);