mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2025-01-02 19:29:17 +00:00
Add lock, unlock and rename to command-line interface (proposed by David Schmidt).
This commit is contained in:
parent
59b9704617
commit
1e6b1d1638
@ -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 <imagename> display information about image.\n-ls <imagename> list brief directory of image.\n-l <imagename> list directory of image.\n-ll <imagename> list detailed directory of image.\n-e <imagename> <filename> export file from image to stdout.\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-cc65 <imagename> <filename> <type> put stdin with cc65 header\n in filename on image, using file type and address from header.\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> display information about image.\n-ls <imagename> list brief directory of image.\n-l <imagename> list directory of image.\n-ll <imagename> list detailed directory of image.\n-e <imagename> <filename> export file from image to stdout.\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-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.
|
||||
|
||||
# UserPreferences
|
||||
UserPreferencesComment = AppleCommander user preferences
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user