diff --git a/src/com/webcodepro/applecommander/ui/UiBundle.properties b/src/com/webcodepro/applecommander/ui/UiBundle.properties index eaa0a23..0bee487 100644 --- a/src/com/webcodepro/applecommander/ui/UiBundle.properties +++ b/src/com/webcodepro/applecommander/ui/UiBundle.properties @@ -100,8 +100,7 @@ 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.\n-ls list brief directory of image.\n-l list directory of image.\n-ll list detailed directory of image.\n-e export file from image to stdout.\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-cc65 put stdin with cc65 header\n in filename on image, using file type and address from header.\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.\n-ls list brief directory of image.\n-l list directory of image.\n-ll list detailed directory of image.\n-e export file from image to stdout.\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-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. # UserPreferences UserPreferencesComment = AppleCommander user preferences diff --git a/src/com/webcodepro/applecommander/ui/ac.java b/src/com/webcodepro/applecommander/ui/ac.java index 0de7473..95f2021 100644 --- a/src/com/webcodepro/applecommander/ui/ac.java +++ b/src/com/webcodepro/applecommander/ui/ac.java @@ -57,6 +57,9 @@ import com.webcodepro.applecommander.util.TextBundle; * -p <imagename> <filename> <type> [[$|0x]<addr>] put stdin * in filename on image, using file type and address [0x2000]. * -d <imagename> <filename> delete file from image. + * -k <imagename> <filename> lock file on image. + * -u <imagename> <filename> unlock file on image. + * -n <imagename> <volname> change volume name (ProDOS or Pascal). * -cc65 <imagename> <filename> <type> put stdin with cc65 header * in filename on image, using file type and address from header. * -dos140 <imagename> create a 140K DOS 3.3 image. @@ -74,6 +77,8 @@ public class ac { try { if (args.length == 0) { help(); + } else if ("-i".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ + getDiskInfo(args[1]); } else if ("-ls".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ showDirectory(args[1], FormattedDisk.FILE_DISPLAY_STANDARD); } else if ("-l".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ @@ -89,8 +94,12 @@ public class ac { (args.length > 4 ? args[4] : "0x2000")); } else if ("-d".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ deleteFile(args[1], args[2]); - } else if ("-i".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ - getDiskInfo(args[1]); + } else if ("-k".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ + setFileLocked(args[1], args[2], true); + } else if ("-u".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ + setFileLocked(args[1], args[2], false); + } else if ("-n".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ + setDiskName(args[1], args[2]); } else if ("-cc65".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ putCC65(args[1], args[2], args[3]); } else if ("-dos140".equalsIgnoreCase(args[0])) { //$NON-NLS-1$ @@ -291,6 +300,42 @@ public class ac { } } + /** + * Set the lockState of the file named fileName on the disk named imageName. + * Proposed by David Schmidt. + */ + static void setFileLocked(String imageName, String fileName, 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]; + List files = formattedDisk.getFiles(); + FileEntry entry = getEntry(files, fileName); + if (entry != null) { + entry.setLocked(lockState); + disk.save(); + } else { + System.err.println(textBundle.format( + "CommandLineNoMatchMessage", fileName)); //$NON-NLS-1$ + } + } + } + + /** + * Set the volume name for a given disk image. + * Only effective for ProDOS or Pascal disks; others ignored. + * Proposed by David Schmidt. + */ + 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(); + } + /** * Create a DOS disk image. */