mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-25 14:32:15 +00:00
link CPM directory entries
This commit is contained in:
parent
8afac62b00
commit
1d7b12bcc9
@ -1,6 +1,7 @@
|
||||
package com.bytezone.diskbrowser.cpm;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.BootSector;
|
||||
@ -17,6 +18,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
||||
public final SectorType cpmSector = new SectorType ("CPM", Color.lightGray);
|
||||
|
||||
private int version; // http://www.seasip.info/Cpm/format22.html
|
||||
private final List<DirectoryEntry> directoryEntries = new ArrayList<DirectoryEntry> ();
|
||||
|
||||
public CPMDisk (Disk disk)
|
||||
{
|
||||
@ -37,7 +39,24 @@ public class CPMDisk extends AbstractFormattedDisk
|
||||
{
|
||||
DiskAddress da = disk.getDiskAddress (3, sector);
|
||||
sectorTypes[da.getBlock ()] = catalogSector;
|
||||
|
||||
buffer = disk.readSector (da);
|
||||
for (int i = 0; i < buffer.length; i += 32)
|
||||
{
|
||||
if (buffer[i] != 0 && buffer[i] != (byte) 0xE5)
|
||||
break;
|
||||
if (buffer[i] == 0)
|
||||
{
|
||||
DirectoryEntry entry = new DirectoryEntry (buffer, i);
|
||||
DirectoryEntry parent = findParent (entry);
|
||||
if (parent == null)
|
||||
directoryEntries.add (entry);
|
||||
else
|
||||
parent.add (entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
listEntries ();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,6 +65,22 @@ public class CPMDisk extends AbstractFormattedDisk
|
||||
return null;
|
||||
}
|
||||
|
||||
public void listEntries ()
|
||||
{
|
||||
for (DirectoryEntry entry : directoryEntries)
|
||||
System.out.println (entry);
|
||||
}
|
||||
|
||||
private DirectoryEntry findParent (DirectoryEntry child)
|
||||
{
|
||||
for (DirectoryEntry entry : directoryEntries)
|
||||
{
|
||||
if (entry.matches (child))
|
||||
return entry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isCorrectFormat (AppleDisk disk)
|
||||
{
|
||||
disk.setInterleave (3);
|
||||
@ -67,10 +102,11 @@ public class CPMDisk extends AbstractFormattedDisk
|
||||
buffer = disk.readSector (3, sector);
|
||||
for (int i = 0; i < buffer.length; i += 32)
|
||||
{
|
||||
if (buffer[i] != 0 && buffer[i] != (byte) 0xE5)
|
||||
int val = buffer[i] & 0xFF;
|
||||
if (val > 31 && val != 0xE5)
|
||||
return false;
|
||||
if (buffer[i] == 0)
|
||||
System.out.println (new DirectoryEntry (buffer, i));
|
||||
// if (buffer[i] == 0)
|
||||
// System.out.println (new DirectoryEntry (buffer, i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.bytezone.diskbrowser.cpm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
public class DirectoryEntry
|
||||
@ -12,6 +15,7 @@ public class DirectoryEntry
|
||||
private final int s2;
|
||||
private final int rc;
|
||||
private final byte[] blockList = new byte[16];
|
||||
private final List<DirectoryEntry> entries = new ArrayList<DirectoryEntry> ();
|
||||
|
||||
public DirectoryEntry (byte[] buffer, int offset)
|
||||
{
|
||||
@ -31,6 +35,11 @@ public class DirectoryEntry
|
||||
&& type.equals (directoryEntry.type);
|
||||
}
|
||||
|
||||
public void add (DirectoryEntry entry)
|
||||
{
|
||||
entries.add (entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
@ -48,6 +57,12 @@ public class DirectoryEntry
|
||||
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
||||
text.append (String.format ("Allocation ..... %s%n", bytes));
|
||||
|
||||
for (DirectoryEntry entry : entries)
|
||||
{
|
||||
bytes = HexFormatter.getHexString (entry.blockList, 0, 16);
|
||||
text.append (String.format (" %s%n", bytes));
|
||||
}
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user