delete issues

This commit is contained in:
Denis Molony 2019-01-26 08:57:35 +11:00
parent adbd1a0292
commit 25948ad218
5 changed files with 47 additions and 25 deletions

View File

@ -118,8 +118,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
return "R";
case AA: // what is this?
return "A";
case BB: // what is this?
return "B";
case BB: // Lisa file
return "L";
default:
System.out.println ("Unknown file type : " + fileType);
return "?";

View File

@ -1,6 +1,7 @@
package com.bytezone.diskbrowser.dos;
import com.bytezone.diskbrowser.applefile.DefaultAppleFile;
import com.bytezone.diskbrowser.disk.AppleDiskAddress;
import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.gui.DataSource;
@ -9,17 +10,35 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
boolean allSectorsAvailable = true;
boolean debug = false;
public DeletedCatalogEntry (DosDisk dosDisk, DiskAddress catalogSector, byte[] entryBuffer)
public DeletedCatalogEntry (DosDisk dosDisk, DiskAddress catalogSector,
byte[] entryBuffer, int dosVersion)
{
super (dosDisk, catalogSector, entryBuffer);
// reportedSize = HexFormatter.intValue (entryBuffer[33], entryBuffer[34]);
if (debug)
{
System.out.println ("Deleted file : " + name);
System.out.printf ("Reported size : %d%n", reportedSize);
}
if (reportedSize <= 1 || !disk.isValidAddress (entryBuffer[32], entryBuffer[1]))
DiskAddress da = null;
// Get address of first TS-list sector
if (dosVersion >= 0x41)
{
int track = entryBuffer[0] & 0x3F;
int sector = entryBuffer[1] & 0x1F;
da = disk.getDiskAddress (track, sector);
}
else
{
int track = entryBuffer[32] & 0xFF;
int sector = entryBuffer[1] & 0xFF;
da = disk.getDiskAddress (track, sector);
}
int totalBlocks = 0;
if (reportedSize <= 1 || !disk.isValidAddress (da.getTrack (), da.getSector ()))
{
if (debug)
System.out.println ("invalid catalog entry");
@ -27,12 +46,8 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
return;
}
// Get address of first TS-list sector
DiskAddress da = disk.getDiskAddress (entryBuffer[32], entryBuffer[1]);
int totalBlocks = 0;
// Loop through all TS-list sectors
loop: while (da.getBlock () > 0)
loop: while (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ())
{
if (!dosDisk.stillAvailable (da))
{
@ -51,7 +66,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
if (da.getBlock () > 0 && debug)
System.out.println (da);
if (da.getBlock () > 0)
if (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ())
{
if (!dosDisk.stillAvailable (da))
{
@ -68,7 +83,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
if (da == null)
{
System.out.printf ("Next T/S list in sector %s is invalid : %02X, %02X%n", da,
sectorBuffer[1], sectorBuffer[2]);
sectorBuffer[1], sectorBuffer[2]);
break;
}
}
@ -99,7 +114,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
public String getDetails ()
{
return String.format ("%-30s %s", name, allSectorsAvailable ? "Recoverable"
: "Not recoverable");
return String.format ("%-30s %s", name,
allSectorsAvailable ? "Recoverable" : "Not recoverable");
}
}

View File

@ -10,7 +10,7 @@ class DosCatalogSector extends AbstractSector
{
private static final String[] fileTypes =
{ "Text file", "Integer Basic program", "Applesoft Basic program", "Binary file",
"SS file", "Relocatable file", "AA file", "BB file" };
"SS file", "Relocatable file", "AA file", "Lisa file" };
private static int CATALOG_ENTRY_SIZE = 35;
private final DosDisk dosDisk;

View File

@ -55,6 +55,7 @@ public class DosDisk extends AbstractFormattedDisk
da = disk.getDiskAddress (CATALOG_TRACK, VTOC_SECTOR);
sectorBuffer = disk.readSector (da); // VTOC
dosVTOCSector = new DosVTOCSector (this, disk, sectorBuffer, da);
sectorTypes[da.getBlock ()] = vtocSector;
DiskAddress catalogStart = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]);
@ -63,7 +64,7 @@ public class DosDisk extends AbstractFormattedDisk
if (dosVTOCSector.maxSectors != disk.getSectorsPerTrack ())
System.out.println ("Invalid sectors per track : " + dosVTOCSector.maxSectors);
sectorTypes[CATALOG_TRACK * dosVTOCSector.maxSectors] = vtocSector;
// sectorTypes[CATALOG_TRACK * dosVTOCSector.maxSectors] = vtocSector;
// assert (maxTracks == disk.getTotalTracks ());
// assert (dosVTOCSector.maxSectors == disk.getSectorsPerTrack ());
@ -91,12 +92,12 @@ public class DosDisk extends AbstractFormattedDisk
// The first byte is officially unused, but it always seems to contain 0x00 or 0xFF
// See beautifulboot.dsk.
if (sectorBuffer[0] != 0 && (sectorBuffer[0] & 0xFF) != 0xFF && false)
{
System.out
.println ("Dos catalog sector buffer byte #0 invalid : " + sectorBuffer[0]);
break;
}
// if (sectorBuffer[0] != 0 && (sectorBuffer[0] & 0xFF) != 0xFF && false)
// {
// System.out
// .println ("Dos catalog sector buffer byte #0 invalid : " + sectorBuffer[0]);
// break;
// }
sectorTypes[da.getBlock ()] = catalogSector;
@ -130,11 +131,14 @@ public class DosDisk extends AbstractFormattedDisk
byte[] entry = new byte[ENTRY_SIZE];
System.arraycopy (sectorBuffer, ptr, entry, 0, ENTRY_SIZE);
int track = entry[0] & 0xFF;
boolean deletedFlag = (entry[0] & 0x80) != 0;
if (entry[0] == (byte) 0xFF) // deleted file
// if (entry[0] == (byte) 0xFF) // deleted file
if (deletedFlag) // deleted file
{
DeletedCatalogEntry deletedCatalogEntry =
new DeletedCatalogEntry (this, da, entry);
new DeletedCatalogEntry (this, da, entry, dosVTOCSector.dosVersion);
deletedFileEntries.add (deletedCatalogEntry);
DefaultMutableTreeNode node = new DefaultMutableTreeNode (deletedCatalogEntry);
node.setAllowsChildren (false);
@ -164,6 +168,7 @@ public class DosDisk extends AbstractFormattedDisk
da = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]);
} while (da.getBlock () != 0);
// link double hi-res files
for (AppleFileSource fe : fileEntries)
{

View File

@ -53,7 +53,9 @@ class DosVTOCSector extends AbstractSector
addText (text, buffer, 5, 1, "Ram DOS " + (char) (buffer[5] & 0x7F));
addTextAndDecimal (text, buffer, 6, 1, "Diskette volume");
addText (text, buffer, 7, 1, "Volume type " + (char) (buffer[7] & 0x7F));
String diskType =
buffer[7] == (byte) 0xC4 ? " = Data" : buffer[7] == (byte) 0xC2 ? " = Boot" : "";
addText (text, buffer, 7, 1, "Volume type: " + (char) (buffer[7] & 0x7F) + diskType);
int ptr = 8;
addText (text, buffer, ptr, 4, "Volume name: " + getName (buffer, ptr));