mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2025-03-12 11:33:08 +00:00
Continue listing after encountering unreadable disk .
This commit is contained in:
parent
4130b3626d
commit
2658e3eb82
@ -46,30 +46,32 @@ import com.webcodepro.applecommander.util.AppleUtil;
|
||||
import com.webcodepro.applecommander.util.TextBundle;
|
||||
|
||||
/**
|
||||
* ac provides a command line interface to key AppleCommander functions.
|
||||
* Text similar to this is produced in response to the -h option.
|
||||
* ac provides a command line interface to key AppleCommander functions. Text
|
||||
* similar to this is produced in response to the -h option.
|
||||
*
|
||||
* <pre>
|
||||
* CommandLineHelp = AppleCommander command line options [{0}]:
|
||||
* -i <imagename> [<imagename>] display information about image(s).
|
||||
* -ls <imagename> [<imagename>] list brief directory of image(s).
|
||||
* -l <imagename> [<imagename>] list directory of image(s).
|
||||
* -ll <imagename> [<imagename>] list detailed directory of image(s).
|
||||
* -e <imagename> <filename> export file from image to stdout.
|
||||
* -g <imagename> <filename> get raw file from image to stdout.
|
||||
* -p <imagename> <filename> <type> [[$|0x]<addr>] put stdin
|
||||
* -i <imagename> [<imagename>] display information about image(s).
|
||||
* -ls <imagename> [<imagename>] list brief directory of image(s).
|
||||
* -l <imagename> [<imagename>] list directory of image(s).
|
||||
* -ll <imagename> [<imagename>] list detailed directory of image(s).
|
||||
* -e <imagename> <filename> export file from image to stdout.
|
||||
* -g <imagename> <filename> get raw file from image to stdout.
|
||||
* -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
|
||||
* -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.
|
||||
* -pro140 <imagename> <volname> create a 140K ProDOS image.
|
||||
* -pro800 <imagename> <volname> create an 800K ProDOS image.
|
||||
* -pas140 <imagename> <volname> create a 140K Pascal image.
|
||||
* -pas800 <imagename> <volname> create an 800K Pascal image.
|
||||
* -dos140 <imagename> create a 140K DOS 3.3 image.
|
||||
* -pro140 <imagename> <volname> create a 140K ProDOS image.
|
||||
* -pro800 <imagename> <volname> create an 800K ProDOS image.
|
||||
* -pas140 <imagename> <volname> create a 140K Pascal image.
|
||||
* -pas800 <imagename> <volname> create an 800K Pascal image.
|
||||
* </pre>
|
||||
*
|
||||
* @author John B. Matthews
|
||||
*/
|
||||
public class ac {
|
||||
@ -129,8 +131,8 @@ public class ac {
|
||||
* Put <stdin> into the file named fileName on the disk named imageName;
|
||||
* Note: only volume level supported; input size unlimited.
|
||||
*/
|
||||
static void putFile(String imageName, String fileName, String fileType, String address)
|
||||
throws IOException, DiskFullException {
|
||||
static void putFile(String imageName, String fileName, String fileType,
|
||||
String address) throws IOException, DiskFullException {
|
||||
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
byte[] inb = new byte[1024];
|
||||
@ -168,7 +170,8 @@ public class ac {
|
||||
/**
|
||||
* Delete the file named fileName from the disk named imageName.
|
||||
*/
|
||||
static void deleteFile(String imageName, String fileName) throws IOException {
|
||||
static void deleteFile(String imageName, String fileName)
|
||||
throws IOException {
|
||||
Disk disk = new Disk(imageName);
|
||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||
for (int i = 0; i < formattedDisks.length; i++) {
|
||||
@ -186,10 +189,11 @@ public class ac {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file named filename from the disk named imageName;
|
||||
* the file is filtered according to its type and sent to <stdout>.
|
||||
* Get the file named filename from the disk named imageName; the file is
|
||||
* filtered according to its type and sent to <stdout>.
|
||||
*/
|
||||
static void getFile(String imageName, String fileName, boolean filter) throws IOException {
|
||||
static void getFile(String imageName, String fileName, boolean filter)
|
||||
throws IOException {
|
||||
Disk disk = new Disk(imageName);
|
||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||
for (int i = 0; i < formattedDisks.length; i++) {
|
||||
@ -215,9 +219,9 @@ public class ac {
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive routine to locate a specific file by filename;
|
||||
* In the instance of a system with directories (e.g. ProDOS),
|
||||
* this really returns the first file with the given filename.
|
||||
* Recursive routine to locate a specific file by filename; In the instance
|
||||
* of a system with directories (e.g. ProDOS), this really returns the first
|
||||
* file with the given filename.
|
||||
*/
|
||||
static FileEntry getEntry(List files, String fileName) {
|
||||
FileEntry theEntry = null;
|
||||
@ -225,14 +229,14 @@ public class ac {
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
FileEntry entry = (FileEntry) files.get(i);
|
||||
String entryName = entry.getFilename();
|
||||
if (!entry.isDeleted() &&
|
||||
fileName.equalsIgnoreCase(entryName)) {
|
||||
if (!entry.isDeleted() && fileName.equalsIgnoreCase(entryName)) {
|
||||
return entry;
|
||||
}
|
||||
if (entry.isDirectory()) {
|
||||
theEntry = getEntry(((DirectoryEntry) entry).
|
||||
getFiles(), fileName);
|
||||
if (theEntry != null) {return theEntry;}
|
||||
theEntry = getEntry(((DirectoryEntry) entry).getFiles(), fileName);
|
||||
if (theEntry != null) {
|
||||
return theEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -244,6 +248,7 @@ public class ac {
|
||||
*/
|
||||
static void showDirectory(String[] args, int display) throws IOException {
|
||||
for (int d = 1; d < args.length; d++) {
|
||||
try {
|
||||
Disk disk = new Disk(args[d]);
|
||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||
for (int i = 0; i < formattedDisks.length; i++) {
|
||||
@ -254,22 +259,23 @@ public class ac {
|
||||
if (files != null) {
|
||||
showFiles(files, "", display); //$NON-NLS-1$
|
||||
}
|
||||
System.out.println(textBundle.format(
|
||||
"CommandLineStatus", //$NON-NLS-1$
|
||||
new Object[] {
|
||||
formattedDisk.getFormat(),
|
||||
System.out.println(textBundle.format("CommandLineStatus", //$NON-NLS-1$
|
||||
new Object[] { formattedDisk.getFormat(),
|
||||
new Integer(formattedDisk.getFreeSpace()),
|
||||
new Integer(formattedDisk.getUsedSpace())
|
||||
}));
|
||||
new Integer(formattedDisk.getUsedSpace()) }));
|
||||
System.out.println();
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
System.out.println(args[d] + ": " + e.getMessage()); //$NON-NLS-1$
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive routine to display directory entries.
|
||||
* In the instance of a system with directories (e.g. ProDOS),
|
||||
* this really returns the first file with the given filename.
|
||||
* Recursive routine to display directory entries. In the instance of a
|
||||
* system with directories (e.g. ProDOS), this really returns the first file
|
||||
* with the given filename.
|
||||
*/
|
||||
static void showFiles(List files, String indent, int display) {
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
@ -284,7 +290,7 @@ public class ac {
|
||||
System.out.println();
|
||||
}
|
||||
if (entry.isDirectory()) {
|
||||
showFiles(((DirectoryEntry)entry).getFiles(),
|
||||
showFiles(((DirectoryEntry) entry).getFiles(),
|
||||
indent + " ", display); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@ -299,7 +305,8 @@ public class ac {
|
||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||
for (int i = 0; i < formattedDisks.length; i++) {
|
||||
FormattedDisk formattedDisk = formattedDisks[i];
|
||||
Iterator iterator = formattedDisk.getDiskInformation().iterator();
|
||||
Iterator iterator = formattedDisk.getDiskInformation()
|
||||
.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
DiskInformation diskinfo = (DiskInformation) iterator.next();
|
||||
System.out.println(diskinfo.getLabel() + ": " + diskinfo.getValue());
|
||||
@ -313,8 +320,8 @@ 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 {
|
||||
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++) {
|
||||
@ -332,9 +339,8 @@ public class ac {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the volume name for a given disk image.
|
||||
* Only effective for ProDOS or Pascal disks; others ignored.
|
||||
* Proposed by David Schmidt.
|
||||
* 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 {
|
||||
@ -352,8 +358,7 @@ public class ac {
|
||||
throws IOException {
|
||||
ByteArrayImageLayout layout = new ByteArrayImageLayout(imageSize);
|
||||
ImageOrder imageOrder = new DosOrder(layout);
|
||||
FormattedDisk[] disks =
|
||||
DosFormatDisk.create(fileName, imageOrder);
|
||||
FormattedDisk[] disks = DosFormatDisk.create(fileName, imageOrder);
|
||||
disks[0].save();
|
||||
}
|
||||
|
||||
@ -364,8 +369,7 @@ public class ac {
|
||||
throws IOException {
|
||||
ByteArrayImageLayout layout = new ByteArrayImageLayout(imageSize);
|
||||
ImageOrder imageOrder = new ProdosOrder(layout);
|
||||
FormattedDisk[] disks =
|
||||
PascalFormatDisk.create(fileName, volName, imageOrder);
|
||||
FormattedDisk[] disks = PascalFormatDisk.create(fileName, volName, imageOrder);
|
||||
disks[0].save();
|
||||
}
|
||||
|
||||
@ -376,8 +380,7 @@ public class ac {
|
||||
throws IOException {
|
||||
ByteArrayImageLayout layout = new ByteArrayImageLayout(imageSize);
|
||||
ImageOrder imageOrder = new ProdosOrder(layout);
|
||||
FormattedDisk[] disks =
|
||||
ProdosFormatDisk.create(fileName, volName, imageOrder);
|
||||
FormattedDisk[] disks = ProdosFormatDisk.create(fileName, volName, imageOrder);
|
||||
disks[0].save();
|
||||
}
|
||||
|
||||
@ -399,7 +402,8 @@ public class ac {
|
||||
}
|
||||
|
||||
static void help() {
|
||||
System.err.println(textBundle.format("CommandLineHelp", AppleCommander.VERSION)); //$NON-NLS-1$
|
||||
System.err.println(textBundle.format(
|
||||
"CommandLineHelp", AppleCommander.VERSION)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user