This commit is contained in:
Denis Molony 2023-03-11 16:35:48 +10:00
parent f4a6465b04
commit 22dfaf65c6
1 changed files with 19 additions and 14 deletions

View File

@ -29,7 +29,8 @@ public class PascalDisk extends AbstractFormattedDisk
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
static final int CATALOG_ENTRY_SIZE = 26; static final int CATALOG_ENTRY_SIZE = 26;
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT); private final DateTimeFormatter dtf =
DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
private final VolumeEntry volumeEntry; private final VolumeEntry volumeEntry;
private final PascalCatalogSector diskCatalogSector; private final PascalCatalogSector diskCatalogSector;
@ -48,8 +49,8 @@ public class PascalDisk extends AbstractFormattedDisk
SectorType fotoSector = new SectorType ("Foto", Color.gray); SectorType fotoSector = new SectorType ("Foto", Color.gray);
SectorType badSector = new SectorType ("Bad", Color.darkGray); SectorType badSector = new SectorType ("Bad", Color.darkGray);
SectorType[] sectors = { catalogSector, badSector, codeSector, textSector, infoSector, dataSector, SectorType[] sectors = { catalogSector, badSector, codeSector, textSector, infoSector,
grafSector, fotoSector }; dataSector, grafSector, fotoSector };
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public PascalDisk (Disk disk) public PascalDisk (Disk disk)
@ -100,7 +101,8 @@ public class PascalDisk extends AbstractFormattedDisk
freeBlocks.set (i, false); freeBlocks.set (i, false);
} }
diskCatalogSector = new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors); diskCatalogSector =
new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors);
// read the catalog // read the catalog
List<DiskAddress> addresses = new ArrayList<> (); List<DiskAddress> addresses = new ArrayList<> ();
@ -297,16 +299,18 @@ public class PascalDisk extends AbstractFormattedDisk
{ {
String newLine = String.format ("%n"); String newLine = String.format ("%n");
String newLine2 = newLine + newLine; String newLine2 = newLine + newLine;
String line = String line = "---- --------------- ---- -------- ------- ---- ---- ----"
"---- --------------- ---- -------- ------- ---- ---- ----" + newLine; + newLine;
String date = volumeEntry.localDate == null ? "--" : volumeEntry.localDate.format (dtf); String date =
volumeEntry.localDate == null ? "--" : volumeEntry.localDate.format (dtf);
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
text.append ("File : " + getDisplayPath () + newLine2); text.append ("File : " + getDisplayPath () + newLine2);
text.append ("Volume : " + volumeEntry.name + newLine); text.append ("Volume : " + volumeEntry.name + newLine);
text.append ("Date : " + date + newLine2); text.append ("Date : " + date + newLine2);
text.append ("Blks Name Type Date Length Frst Last Blks\n"); text.append (
"Blks Name Type Date Length Frst Last Blks\n");
text.append (line); text.append (line);
int usedBlocks = 6; int usedBlocks = 6;
@ -319,15 +323,16 @@ public class PascalDisk extends AbstractFormattedDisk
date = ce.localDate == null ? "--" : ce.localDate.format (dtf); date = ce.localDate == null ? "--" : ce.localDate.format (dtf);
int bytes = (size - 1) * 512 + ce.bytesUsedInLastBlock; int bytes = (size - 1) * 512 + ce.bytesUsedInLastBlock;
String fileType = String fileType = ce.fileType < 0 || ce.fileType >= fileTypes.length ? "????"
ce.fileType < 0 || ce.fileType >= fileTypes.length ? "????" : fileTypes[ce.fileType]; : fileTypes[ce.fileType];
text.append (String.format ("%4d %-15s %-6s %8s %,8d $%03X $%03X $%03X%n", size, text.append (String.format ("%4d %-15s %-6s %8s %,8d $%03X $%03X $%03X%n",
ce.name, fileType, date, bytes, ce.firstBlock, ce.lastBlock, size)); size, ce.name, fileType, date, bytes, ce.firstBlock, ce.lastBlock, size));
} }
text.append (line); text.append (line);
text.append (String.format ("Blocks free : %3d Blocks used : %3d Total blocks : %3d%n", text.append (
(volumeEntry.totalBlocks - usedBlocks), usedBlocks, volumeEntry.totalBlocks)); String.format ("Blocks free : %3d Blocks used : %3d Total blocks : %3d%n",
(volumeEntry.totalBlocks - usedBlocks), usedBlocks, volumeEntry.totalBlocks));
return new DefaultAppleFileSource (volumeEntry.name, text.toString (), this); return new DefaultAppleFileSource (volumeEntry.name, text.toString (), this);
} }