read only and system file

This commit is contained in:
Denis Molony 2016-02-27 10:10:00 +11:00
parent dee3c48dcb
commit 9b2e621ecd
3 changed files with 52 additions and 7 deletions

View File

@ -22,10 +22,31 @@ public class CPMCatalogSector extends AbstractSector
if (buffer[i] == (byte) 0xE5) if (buffer[i] == (byte) 0xE5)
break; break;
boolean readOnly = (buffer[i + 9] & 0x80) != 0;
boolean systemFile = (buffer[i + 10] & 0x80) != 0;
String type;
String extra;
if (readOnly || systemFile)
{
byte[] typeBuffer = new byte[3];
typeBuffer[0] = (byte) (buffer[i + 9] & 0x7F);
typeBuffer[1] = (byte) (buffer[i + 10] & 0x7F);
typeBuffer[2] = buffer[i + 11];
type = new String (typeBuffer).trim ();
extra = String.format (" (%s%s)", readOnly ? "read only" : "",
systemFile ? "system file" : "");
}
else
{
type = new String (buffer, i + 9, 3).trim ();
extra = "";
}
addText (text, buffer, i, 1, "User number"); addText (text, buffer, i, 1, "User number");
addText (text, buffer, i + 1, 4, "File name : " + new String (buffer, i + 1, 8)); addText (text, buffer, i + 1, 4, "File name : " + new String (buffer, i + 1, 8));
addText (text, buffer, i + 5, 4, ""); addText (text, buffer, i + 5, 4, "");
addText (text, buffer, i + 9, 3, "File type : " + new String (buffer, i + 9, 3)); addText (text, buffer, i + 9, 3, "File type : " + type + extra);
addText (text, buffer, i + 12, 1, "Extent counter LO"); addText (text, buffer, i + 12, 1, "Extent counter LO");
addText (text, buffer, i + 13, 1, "Reserved"); addText (text, buffer, i + 13, 1, "Reserved");
addText (text, buffer, i + 14, 1, "Extent counter HI"); addText (text, buffer, i + 14, 1, "Extent counter HI");

View File

@ -134,11 +134,11 @@ public class CPMDisk extends AbstractFormattedDisk
{ {
String newLine = String.format ("%n"); String newLine = String.format ("%n");
String line = String line =
"---- --------- --- -- -- -- -- ----------------------------" "---- --------- --- - - -- -- -- -- ----------------------------"
+ "-------------------" + newLine; + "-------------------" + newLine;
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
text.append (String.format ("Disk : %s%n%n", getAbsolutePath ())); text.append (String.format ("Disk : %s%n%n", getAbsolutePath ()));
text.append ("User Name Typ Ex S2 S1 RC Blocks" + newLine); text.append ("User Name Typ R S Ex S2 S1 RC Blocks" + newLine);
text.append (line); text.append (line);
for (AppleFileSource entry : fileEntries) for (AppleFileSource entry : fileEntries)

View File

@ -28,15 +28,30 @@ public class DirectoryEntry implements AppleFileSource
private final List<DirectoryEntry> entries = new ArrayList<DirectoryEntry> (); private final List<DirectoryEntry> entries = new ArrayList<DirectoryEntry> ();
private final List<DiskAddress> blocks = new ArrayList<DiskAddress> (); private final List<DiskAddress> blocks = new ArrayList<DiskAddress> ();
private DataSource appleFile; private DataSource appleFile;
private final boolean readOnly;
private final boolean systemFile;
public DirectoryEntry (CPMDisk parent, byte[] buffer, int offset) public DirectoryEntry (CPMDisk parent, byte[] buffer, int offset)
{ {
this.parent = parent; this.parent = parent;
disk = parent.getDisk (); disk = parent.getDisk ();
readOnly = (buffer[offset + 9] & 0x80) != 0;
systemFile = (buffer[offset + 10] & 0x80) != 0;
if (readOnly || systemFile)
{
byte[] typeBuffer = new byte[3];
typeBuffer[0] = (byte) (buffer[offset + 9] & 0x7F);
typeBuffer[1] = (byte) (buffer[offset + 10] & 0x7F);
typeBuffer[2] = buffer[offset + 11];
type = new String (typeBuffer).trim ();
}
else
type = new String (buffer, offset + 9, 3).trim ();
userNumber = buffer[offset] & 0xFF; userNumber = buffer[offset] & 0xFF;
name = new String (buffer, offset + 1, 8).trim (); name = new String (buffer, offset + 1, 8).trim ();
type = new String (buffer, offset + 9, 3).trim ();
ex = buffer[offset + 12] & 0xFF; ex = buffer[offset + 12] & 0xFF;
s2 = buffer[offset + 13] & 0xFF; s2 = buffer[offset + 13] & 0xFF;
s1 = buffer[offset + 14] & 0xFF; s1 = buffer[offset + 14] & 0xFF;
@ -100,8 +115,12 @@ public class DirectoryEntry implements AppleFileSource
String bytes = HexFormatter.getHexString (blockList, 0, 16); String bytes = HexFormatter.getHexString (blockList, 0, 16);
bytes = bytes.replaceAll ("00", " "); bytes = bytes.replaceAll ("00", " ");
String text = String.format ("%3d %-8s %-3s %02X %02X %02X %02X %s", char ro = readOnly ? '*' : ' ';
userNumber, name, type, ex, s2, s1, rc, bytes); char sf = systemFile ? '*' : ' ';
String text =
String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
userNumber, name, type, ro, sf, ex, s2, s1, rc, bytes);
for (DirectoryEntry entry : entries) for (DirectoryEntry entry : entries)
text = text + "\n" + entry.line (); text = text + "\n" + entry.line ();
@ -170,7 +189,12 @@ public class DirectoryEntry implements AppleFileSource
++count; ++count;
} }
if ("ASM".equals (type) || "DOC".equals (type) || "TXT".equals (type) || count > 0) if ("COM".equals (type))
appleFile = new DefaultAppleFile (name, exactBuffer, "COM File");
else if ("DVR".equals (type))
appleFile = new DefaultAppleFile (name, exactBuffer, "DVR File");
else if ("ASM".equals (type) || "DOC".equals (type) || "TXT".equals (type)
|| count > 2)
appleFile = new CPMTextFile (name, exactBuffer); appleFile = new CPMTextFile (name, exactBuffer);
else else
appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + type); appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + type);