Display correct case in disk table

This commit is contained in:
Denis Molony 2016-12-16 12:19:59 +11:00
parent 4c0494410e
commit ee3496309b
4 changed files with 29 additions and 11 deletions

View File

@ -21,6 +21,8 @@ public class CPMTextFile extends AbstractFile
String line = getLine (ptr); String line = getLine (ptr);
text.append (line + "\n"); text.append (line + "\n");
ptr += line.length () + 2; ptr += line.length () + 2;
while (ptr < buffer.length && buffer[ptr] == 0)
++ptr;
} }
if (text.length () > 0) if (text.length () > 0)

View File

@ -41,10 +41,16 @@ public class CPMDisk extends AbstractFormattedDisk
setEmptyByte ((byte) 0xE5); setEmptyByte ((byte) 0xE5);
byte[] buffer = disk.readSector (0, 8); for (int i = 8; i >= 4; i -= 2)
{
byte[] buffer = disk.readSector (0, i);
String text = new String (buffer, 16, 24); String text = new String (buffer, 16, 24);
if ("DIR ERA TYPESAVEREN USER".equals (text)) if ("DIR ERA TYPESAVEREN USER".equals (text))
{
version = buffer[41] & 0xFF; version = buffer[41] & 0xFF;
break;
}
}
DefaultMutableTreeNode root = getCatalogTreeRoot (); DefaultMutableTreeNode root = getCatalogTreeRoot ();
@ -55,7 +61,7 @@ public class CPMDisk extends AbstractFormattedDisk
break; break;
sectorTypes[da.getBlock ()] = catalogSector; sectorTypes[da.getBlock ()] = catalogSector;
buffer = disk.readSector (da); byte[] buffer = disk.readSector (da);
for (int i = 0; i < buffer.length; i += 32) for (int i = 0; i < buffer.length; i += 32)
{ {
@ -166,8 +172,12 @@ public class CPMDisk extends AbstractFormattedDisk
byte[] buffer = disk.readSector (0, i); byte[] buffer = disk.readSector (0, i);
String text = new String (buffer, 16, 24); String text = new String (buffer, 16, 24);
if ("DIR ERA TYPESAVEREN USER".equals (text)) if ("DIR ERA TYPESAVEREN USER".equals (text))
{
int version = buffer[41] & 0xFF;
System.out.printf ("CPM version %d%n", version);
return true; return true;
} }
}
for (int sector = 0; sector < 8; sector++) for (int sector = 0; sector < 8; sector++)
{ {
@ -177,14 +187,13 @@ public class CPMDisk extends AbstractFormattedDisk
if (bufferContainsAll (buffer, (byte) 0xE5)) if (bufferContainsAll (buffer, (byte) 0xE5))
break; break;
// System.out.println (HexFormatter.format (buffer));
for (int i = 0; i < buffer.length; i += 32) for (int i = 0; i < buffer.length; i += 32)
{ {
int val = buffer[i] & 0xFF; int val = buffer[i] & 0xFF;
// System.out.printf ("%02X%n", val); if (val == 0xE5)
// if (val == 0xE5) break;
// break;
if (val > 31 && val != 0xE5) if (val > 31) // && val != 0xE5)
return false; return false;
for (int j = 1; j <= 8; j++) for (int j = 1; j <= 8; j++)

View File

@ -84,6 +84,11 @@ public class DiskDetails
return shortName; return shortName;
} }
public String getFileName ()
{
return file.getName ();
}
public long calculateChecksum () public long calculateChecksum ()
{ {
checksum = ComputeCRC32.getChecksumValue (file); checksum = ComputeCRC32.getChecksumValue (file);

View File

@ -70,7 +70,7 @@ public class DiskTableModel extends AbstractTableModel
case 0: case 0:
return line.path; return line.path;
case 1: case 1:
return line.shortName; return line.fileName;
case 2: case 2:
return line.type; return line.type;
case 3: case 3:
@ -104,6 +104,7 @@ public class DiskTableModel extends AbstractTableModel
class TableLine class TableLine
{ {
private final String shortName; private final String shortName;
private final String fileName;
private final String path; private final String path;
private long checksum; private long checksum;
private final int duplicateNames; private final int duplicateNames;
@ -116,6 +117,7 @@ public class DiskTableModel extends AbstractTableModel
{ {
this.diskDetails = diskDetails; this.diskDetails = diskDetails;
shortName = diskDetails.getShortName (); shortName = diskDetails.getShortName ();
fileName = diskDetails.getFileName ();
checksum = diskDetails.getChecksum (); checksum = diskDetails.getChecksum ();
type = Utility.getSuffix (shortName); type = Utility.getSuffix (shortName);
size = diskDetails.getFile ().length (); size = diskDetails.getFile ().length ();