mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2025-02-13 04:30:37 +00:00
Protect ourselves from writing SDKs back out
Add the ability to uncompress SDK
This commit is contained in:
parent
4ab21617fa
commit
a79df8f3bc
@ -102,7 +102,8 @@ CreateDirectoryMenuItem=Create Directory...
|
|||||||
CommandLineErrorMessage = Error: {0}
|
CommandLineErrorMessage = Error: {0}
|
||||||
CommandLineNoMatchMessage = {0}: No match.
|
CommandLineNoMatchMessage = {0}: No match.
|
||||||
CommandLineStatus = {0} format; {1} bytes free; {2} bytes used.
|
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.
|
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
|
||||||
|
|
||||||
# UserPreferences
|
# UserPreferences
|
||||||
UserPreferencesComment = AppleCommander user preferences
|
UserPreferencesComment = AppleCommander user preferences
|
||||||
|
@ -77,6 +77,8 @@ import com.webcodepro.applecommander.util.TextBundle;
|
|||||||
* -pro800 <imagename> <volname> create an 800K ProDOS image.
|
* -pro800 <imagename> <volname> create an 800K ProDOS image.
|
||||||
* -pas140 <imagename> <volname> create a 140K Pascal image.
|
* -pas140 <imagename> <volname> create a 140K Pascal image.
|
||||||
* -pas800 <imagename> <volname> create an 800K Pascal image.
|
* -pas800 <imagename> <volname> create an 800K Pascal image.
|
||||||
|
* -unshrink <shrinksdk> <imagename> uncompress a ShrinkIt disk image
|
||||||
|
* into a normal disk image.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author John B. Matthews
|
* @author John B. Matthews
|
||||||
@ -127,6 +129,8 @@ public class ac {
|
|||||||
createProDisk(args[1], args[2], Disk.APPLE_140KB_DISK);
|
createProDisk(args[1], args[2], Disk.APPLE_140KB_DISK);
|
||||||
} else if ("-pro800".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
} else if ("-pro800".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||||
createProDisk(args[1], args[2], Disk.APPLE_800KB_DISK);
|
createProDisk(args[1], args[2], Disk.APPLE_800KB_DISK);
|
||||||
|
} else if ("-unshrink".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||||
|
unshrink(args[1], args[2]);
|
||||||
} else {
|
} else {
|
||||||
help();
|
help();
|
||||||
}
|
}
|
||||||
@ -185,18 +189,22 @@ public class ac {
|
|||||||
buf.write(inb, 0, byteCount);
|
buf.write(inb, 0, byteCount);
|
||||||
}
|
}
|
||||||
Disk disk = new Disk(imageName);
|
Disk disk = new Disk(imageName);
|
||||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
if (!disk.isSDK()) {
|
||||||
FormattedDisk formattedDisk = formattedDisks[0];
|
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||||
FileEntry entry = name.createEntry(formattedDisk);
|
FormattedDisk formattedDisk = formattedDisks[0];
|
||||||
if (entry != null) {
|
FileEntry entry = name.createEntry(formattedDisk);
|
||||||
entry.setFiletype(fileType);
|
if (entry != null) {
|
||||||
entry.setFilename(name.name);
|
entry.setFiletype(fileType);
|
||||||
entry.setFileData(buf.toByteArray());
|
entry.setFilename(name.name);
|
||||||
if (entry.needsAddress()) {
|
entry.setFileData(buf.toByteArray());
|
||||||
entry.setAddress(stringToInt(address));
|
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)
|
static void deleteFile(String imageName, Name name)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Disk disk = new Disk(imageName);
|
Disk disk = new Disk(imageName);
|
||||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
if (!disk.isSDK()) {
|
||||||
for (int i = 0; i < formattedDisks.length; i++) {
|
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||||
FormattedDisk formattedDisk = formattedDisks[i];
|
for (int i = 0; i < formattedDisks.length; i++) {
|
||||||
FileEntry entry = name.getEntry(formattedDisk);
|
FormattedDisk formattedDisk = formattedDisks[i];
|
||||||
if (entry != null) {
|
FileEntry entry = name.getEntry(formattedDisk);
|
||||||
entry.delete();
|
if (entry != null) {
|
||||||
disk.save();
|
entry.delete();
|
||||||
} else {
|
disk.save();
|
||||||
System.err.println(textBundle.format(
|
} else {
|
||||||
"CommandLineNoMatchMessage", name.fullName)); //$NON-NLS-1$
|
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,
|
static void setFileLocked(String imageName, Name name,
|
||||||
boolean lockState) throws IOException {
|
boolean lockState) throws IOException {
|
||||||
Disk disk = new Disk(imageName);
|
Disk disk = new Disk(imageName);
|
||||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
if (!disk.isSDK()) {
|
||||||
for (int i = 0; i < formattedDisks.length; i++) {
|
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||||
FormattedDisk formattedDisk = formattedDisks[i];
|
for (int i = 0; i < formattedDisks.length; i++) {
|
||||||
FileEntry entry = name.getEntry(formattedDisk);
|
FormattedDisk formattedDisk = formattedDisks[i];
|
||||||
if (entry != null) {
|
FileEntry entry = name.getEntry(formattedDisk);
|
||||||
entry.setLocked(lockState);
|
if (entry != null) {
|
||||||
disk.save();
|
entry.setLocked(lockState);
|
||||||
} else {
|
disk.save();
|
||||||
System.err.println(textBundle.format(
|
} else {
|
||||||
"CommandLineNoMatchMessage", name.fullName)); //$NON-NLS-1$
|
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)
|
public static void setDiskName(String imageName, String volName)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Disk disk = new Disk(imageName);
|
Disk disk = new Disk(imageName);
|
||||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
if (!disk.isSDK()) {
|
||||||
FormattedDisk formattedDisk = formattedDisks[0];
|
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||||
formattedDisk.setDiskName(volName);
|
FormattedDisk formattedDisk = formattedDisks[0];
|
||||||
formattedDisks[0].save();
|
formattedDisk.setDiskName(volName);
|
||||||
|
formattedDisks[0].save();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new IOException(textBundle.get("CommandLineSDKReadOnly"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -491,6 +511,30 @@ public class ac {
|
|||||||
disks[0].save();
|
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) {
|
static int stringToInt(String s) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user