show extra bytes for binary files

This commit is contained in:
Denis Molony 2016-02-05 11:23:53 +11:00
parent 62206d25d7
commit fc50481a58
6 changed files with 156 additions and 84 deletions

View File

@ -1,3 +0,0 @@
#Build Number for ANT. Do not edit!
#Mon Dec 14 07:20:11 AEDT 2015
build.number=633

View File

@ -53,15 +53,19 @@ public abstract class AbstractFile implements DataSource
text.append (hb.title + "\n\n"); text.append (hb.title + "\n\n");
text.append (HexFormatter.format (buffer, hb.ptr, hb.size) + "\n\n"); text.append (HexFormatter.format (buffer, hb.ptr, hb.size) + "\n\n");
} }
text.deleteCharAt (text.length () - 1); text.deleteCharAt (text.length () - 1);
text.deleteCharAt (text.length () - 1); text.deleteCharAt (text.length () - 1);
return text.toString (); return text.toString ();
} }
if (buffer == null || buffer.length == 0) if (buffer == null || buffer.length == 0)
return "No buffer"; return "No buffer";
if (buffer.length <= 99999) if (buffer.length <= 99999)
return HexFormatter.format (buffer, 0, buffer.length); return HexFormatter.format (buffer, 0, buffer.length);
return HexFormatter.format (buffer, 0, 99999); return HexFormatter.format (buffer, 0, 99999);
} }

View File

@ -9,13 +9,19 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.bytezone.diskbrowser.HexFormatter;
import com.bytezone.diskbrowser.gui.DiskBrowser; import com.bytezone.diskbrowser.gui.DiskBrowser;
public class AssemblerProgram extends AbstractFile public class AssemblerProgram extends AbstractFile
{ {
private static Map<Integer, String> equates;
private final int loadAddress; private final int loadAddress;
private int executeOffset; private int executeOffset;
private static Map<Integer, String> equates;
private byte[] extraBuffer;
// private int offset;
// private int length;
public AssemblerProgram (String name, byte[] buffer, int address) public AssemblerProgram (String name, byte[] buffer, int address)
{ {
@ -32,6 +38,39 @@ public class AssemblerProgram extends AbstractFile
this.executeOffset = executeOffset; this.executeOffset = executeOffset;
} }
public void setExtraBuffer (byte[] fullBuffer, int offset, int length)
{
this.extraBuffer = new byte[length];
System.arraycopy (fullBuffer, offset, extraBuffer, 0, length);
}
@Override
public String getHexDump ()
{
String text = super.getHexDump ();
if (extraBuffer == null)
return text;
return text + "\n\n"
+ HexFormatter.format (extraBuffer, 0, extraBuffer.length, buffer.length);
}
@Override
public String getAssembler ()
{
String text = super.getAssembler ();
if (extraBuffer == null)
return text;
String extraName = String.format ("%s (extra)", name);
AssemblerProgram assemblerProgram =
new AssemblerProgram (extraName, extraBuffer, buffer.length);
return text + "\n\n" + assemblerProgram.getText ();
}
@Override @Override
public String getText () public String getText ()
{ {
@ -45,10 +84,10 @@ public class AssemblerProgram extends AbstractFile
pgm.append (String.format ("Entry : $%04X%n", (loadAddress + executeOffset))); pgm.append (String.format ("Entry : $%04X%n", (loadAddress + executeOffset)));
pgm.append (String.format ("%n")); pgm.append (String.format ("%n"));
return pgm.append (getStringBuilder ()).toString (); return pgm.append (getStringBuilder2 ()).toString ();
} }
public StringBuilder getStringBuilder () private StringBuilder getStringBuilder ()
{ {
if (true) if (true)
return getStringBuilder2 (); return getStringBuilder2 ();
@ -58,7 +97,8 @@ public class AssemblerProgram extends AbstractFile
int ptr = executeOffset; int ptr = executeOffset;
int address = loadAddress + executeOffset; int address = loadAddress + executeOffset;
// if the assembly doesn't start at the beginning, just dump the bytes that are skipped // if the assembly doesn't start at the beginning, just dump the bytes that
// are skipped
for (int i = 0; i < executeOffset; i++) for (int i = 0; i < executeOffset; i++)
pgm.append (String.format ("%04X: %02X%n", (loadAddress + i), buffer[i])); pgm.append (String.format ("%04X: %02X%n", (loadAddress + i), buffer[i]));
@ -88,7 +128,7 @@ public class AssemblerProgram extends AbstractFile
} }
if (cmd.target > 0 if (cmd.target > 0
&& (cmd.target < loadAddress - 1 || cmd.target > (loadAddress + buffer.length))) && (cmd.target < loadAddress - 1 || cmd.target > (loadAddress + buffer.length)))
{ {
while (line.length () < 40) while (line.length () < 40)
line.append (" "); line.append (" ");
@ -115,12 +155,13 @@ public class AssemblerProgram extends AbstractFile
return pgm; return pgm;
} }
public StringBuilder getStringBuilder2 () private StringBuilder getStringBuilder2 ()
{ {
StringBuilder pgm = new StringBuilder (); StringBuilder pgm = new StringBuilder ();
List<AssemblerStatement> lines = getLines (); List<AssemblerStatement> lines = getLines ();
// if the assembly doesn't start at the beginning, just dump the bytes that are skipped // if the assembly doesn't start at the beginning, just dump the bytes that
// are skipped
for (int i = 0; i < executeOffset; i++) for (int i = 0; i < executeOffset; i++)
pgm.append (String.format (" %04X: %02X%n", (loadAddress + i), buffer[i])); pgm.append (String.format (" %04X: %02X%n", (loadAddress + i), buffer[i]));
@ -128,7 +169,8 @@ public class AssemblerProgram extends AbstractFile
{ {
StringBuilder line = new StringBuilder (); StringBuilder line = new StringBuilder ();
line.append (String.format ("%3.3s %04X: %02X ", getArrow (cmd), cmd.address, cmd.value)); line.append (String.format ("%3.3s %04X: %02X ", getArrow (cmd), cmd.address,
cmd.value));
if (cmd.size > 1) if (cmd.size > 1)
line.append (String.format ("%02X ", cmd.operand1)); line.append (String.format ("%02X ", cmd.operand1));
@ -146,7 +188,7 @@ public class AssemblerProgram extends AbstractFile
} }
if (cmd.target > 0 if (cmd.target > 0
&& (cmd.target < loadAddress - 1 || cmd.target > (loadAddress + buffer.length))) && (cmd.target < loadAddress - 1 || cmd.target > (loadAddress + buffer.length)))
{ {
while (line.length () < 40) while (line.length () < 40)
line.append (" "); line.append (" ");
@ -174,7 +216,8 @@ public class AssemblerProgram extends AbstractFile
private List<AssemblerStatement> getLines () private List<AssemblerStatement> getLines ()
{ {
List<AssemblerStatement> lines = new ArrayList<AssemblerStatement> (); List<AssemblerStatement> lines = new ArrayList<AssemblerStatement> ();
Map<Integer, AssemblerStatement> linesMap = new HashMap<Integer, AssemblerStatement> (); Map<Integer, AssemblerStatement> linesMap =
new HashMap<Integer, AssemblerStatement> ();
List<Integer> targets = new ArrayList<Integer> (); List<Integer> targets = new ArrayList<Integer> ();
int ptr = executeOffset; int ptr = executeOffset;
@ -195,7 +238,7 @@ public class AssemblerProgram extends AbstractFile
cmd.size = 1; cmd.size = 1;
if (cmd.target >= loadAddress && cmd.target < (loadAddress + buffer.length) if (cmd.target >= loadAddress && cmd.target < (loadAddress + buffer.length)
&& (cmd.value == 0x4C || cmd.value == 0x6C || cmd.value == 0x20)) && (cmd.value == 0x4C || cmd.value == 0x6C || cmd.value == 0x20))
targets.add (cmd.target); targets.add (cmd.target);
if (cmd.offset != 0) if (cmd.offset != 0)
targets.add (cmd.address + cmd.offset + 2); targets.add (cmd.address + cmd.offset + 2);
@ -220,7 +263,7 @@ public class AssemblerProgram extends AbstractFile
if (cmd.value == 0x4C || cmd.value == 0x6C || cmd.value == 0x60 || cmd.offset != 0) if (cmd.value == 0x4C || cmd.value == 0x6C || cmd.value == 0x60 || cmd.offset != 0)
arrow = "<--"; arrow = "<--";
if (cmd.value == 0x20 && // JSR if (cmd.value == 0x20 && // JSR
cmd.target >= loadAddress && cmd.target < (loadAddress + buffer.length)) cmd.target >= loadAddress && cmd.target < (loadAddress + buffer.length))
arrow = "<--"; arrow = "<--";
if (cmd.isTarget) if (cmd.isTarget)
if (arrow.isEmpty ()) if (arrow.isEmpty ())
@ -230,18 +273,12 @@ public class AssemblerProgram extends AbstractFile
return arrow; return arrow;
} }
@Override
public String getAssembler ()
{
return getStringBuilder ().toString ();
}
private void getEquates () private void getEquates ()
{ {
equates = new HashMap<Integer, String> (); equates = new HashMap<Integer, String> ();
DataInputStream inputEquates = DataInputStream inputEquates =
new DataInputStream (DiskBrowser.class.getClassLoader () new DataInputStream (DiskBrowser.class.getClassLoader ()
.getResourceAsStream ("com/bytezone/diskbrowser/applefile/equates.txt")); .getResourceAsStream ("com/bytezone/diskbrowser/applefile/equates.txt"));
BufferedReader in = new BufferedReader (new InputStreamReader (inputEquates)); BufferedReader in = new BufferedReader (new InputStreamReader (inputEquates));
String line; String line;

View File

@ -27,7 +27,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
protected final List<DiskAddress> dataSectors = new ArrayList<DiskAddress> (); protected final List<DiskAddress> dataSectors = new ArrayList<DiskAddress> ();
protected final List<DiskAddress> tsSectors = new ArrayList<DiskAddress> (); protected final List<DiskAddress> tsSectors = new ArrayList<DiskAddress> ();
public AbstractCatalogEntry (DosDisk dosDisk, DiskAddress catalogSector, byte[] entryBuffer) public AbstractCatalogEntry (DosDisk dosDisk, DiskAddress catalogSector,
byte[] entryBuffer)
{ {
this.dosDisk = dosDisk; this.dosDisk = dosDisk;
this.disk = dosDisk.getDisk (); this.disk = dosDisk.getDisk ();
@ -58,9 +59,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
name = getName ("", entryBuffer); name = getName ("", entryBuffer);
// CATALOG command only formats the LO byte - see Beneath Apple DOS pp4-6 // CATALOG command only formats the LO byte - see Beneath Apple DOS pp4-6
String base = String base = String.format ("%s%s %03d ", (locked) ? "*" : " ", getFileType (),
String.format ("%s%s %03d ", (locked) ? "*" : " ", getFileType (), (entryBuffer[33] & 0xFF));
(entryBuffer[33] & 0xFF));
catalogName = getName (base, entryBuffer); catalogName = getName (base, entryBuffer);
} }
@ -140,6 +140,9 @@ abstract class AbstractCatalogEntry implements AppleFileSource
try try
{ {
byte[] exactBuffer;
byte[] extraBuffer = new byte[0];
switch (this.fileType) switch (this.fileType)
{ {
case Text: case Text:
@ -148,12 +151,14 @@ abstract class AbstractCatalogEntry implements AppleFileSource
else else
appleFile = new TextFile (name, buffer); appleFile = new TextFile (name, buffer);
break; break;
case IntegerBasic: case IntegerBasic:
reportedLength = HexFormatter.intValue (buffer[0], buffer[1]); reportedLength = HexFormatter.intValue (buffer[0], buffer[1]);
byte[] exactBuffer = new byte[reportedLength]; exactBuffer = new byte[reportedLength];
System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength); System.arraycopy (buffer, 2, exactBuffer, 0, reportedLength);
appleFile = new IntegerBasicProgram (name, exactBuffer); appleFile = new IntegerBasicProgram (name, exactBuffer);
break; break;
case ApplesoftBasic: case ApplesoftBasic:
reportedLength = HexFormatter.intValue (buffer[0], buffer[1]); reportedLength = HexFormatter.intValue (buffer[0], buffer[1]);
exactBuffer = new byte[reportedLength]; exactBuffer = new byte[reportedLength];
@ -163,8 +168,9 @@ abstract class AbstractCatalogEntry implements AppleFileSource
// appleFile = new ApplesoftBasicProgram (name, exactBuffer); // appleFile = new ApplesoftBasicProgram (name, exactBuffer);
appleFile = new BasicProgram (name, exactBuffer); appleFile = new BasicProgram (name, exactBuffer);
break; break;
case Binary: // binary file
case Relocatable: // relocatable binary file case Binary: // binary file
case Relocatable: // relocatable binary file
if (buffer.length == 0) if (buffer.length == 0)
appleFile = new AssemblerProgram (name, buffer, 0); appleFile = new AssemblerProgram (name, buffer, 0);
else else
@ -174,15 +180,21 @@ abstract class AbstractCatalogEntry implements AppleFileSource
if (reportedLength == 0) if (reportedLength == 0)
{ {
System.out.println (name.trim () + " reported length : 0 - reverting to " System.out.println (name.trim () + " reported length : 0 - reverting to "
+ (buffer.length - 4)); + (buffer.length - 4));
reportedLength = buffer.length - 4; reportedLength = buffer.length - 4;
} }
// buffer is a multiple of the block size, so it usually needs to be reduced // buffer is a multiple of the block size, so it usually needs to be reduced
if ((reportedLength + 4) <= buffer.length) if ((reportedLength + 4) <= buffer.length)
{
exactBuffer = new byte[reportedLength]; exactBuffer = new byte[reportedLength];
// extraBuffer = new byte[buffer.length - reportedLength - 4];
// System.arraycopy (buffer, reportedLength + 4, extraBuffer, 0,
// extraBuffer.length);
}
else else
exactBuffer = new byte[buffer.length - 4]; // reported length is too long exactBuffer = new byte[buffer.length - 4]; // reported length is too long
System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length); System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length);
if (ShapeTable.isShapeTable (exactBuffer)) if (ShapeTable.isShapeTable (exactBuffer))
@ -192,7 +204,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
else if (loadAddress == 0x2000 || loadAddress == 0x4000) else if (loadAddress == 0x2000 || loadAddress == 0x4000)
{ {
if ((reportedLength > 0x1F00 && reportedLength <= 0x4000) if ((reportedLength > 0x1F00 && reportedLength <= 0x4000)
|| ((name.equals ("FLY LOGO") && reportedLength == 0x14FA))) || ((name.equals ("FLY LOGO") && reportedLength == 0x14FA)))
appleFile = new HiResImage (name, exactBuffer); appleFile = new HiResImage (name, exactBuffer);
// else if // else if
// appleFile = new HiResImage (name, unscrunch (exactBuffer)); // appleFile = new HiResImage (name, unscrunch (exactBuffer));
@ -202,24 +214,34 @@ abstract class AbstractCatalogEntry implements AppleFileSource
else if (name.endsWith (".S")) else if (name.endsWith (".S"))
appleFile = new MerlinSource (name, exactBuffer); appleFile = new MerlinSource (name, exactBuffer);
else else
{
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress); appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
if (exactBuffer.length < buffer.length + 4)
((AssemblerProgram) appleFile)
.setExtraBuffer (buffer, reportedLength + 4,
buffer.length - reportedLength - 4);
}
} }
break; break;
case SS: // what is this?
case SS: // what is this?
System.out.println ("SS file"); System.out.println ("SS file");
appleFile = new DefaultAppleFile (name, buffer); appleFile = new DefaultAppleFile (name, buffer);
break; break;
case AA: // what is this?
case AA: // what is this?
System.out.println ("AA file"); System.out.println ("AA file");
appleFile = new DefaultAppleFile (name, buffer); appleFile = new DefaultAppleFile (name, buffer);
break; break;
case BB: // what is this?
case BB: // what is this?
int loadAddress = HexFormatter.intValue (buffer[0], buffer[1]); int loadAddress = HexFormatter.intValue (buffer[0], buffer[1]);
reportedLength = HexFormatter.intValue (buffer[2], buffer[3]); reportedLength = HexFormatter.intValue (buffer[2], buffer[3]);
exactBuffer = new byte[reportedLength]; exactBuffer = new byte[reportedLength];
System.arraycopy (buffer, 4, exactBuffer, 0, reportedLength); System.arraycopy (buffer, 4, exactBuffer, 0, reportedLength);
appleFile = new SimpleText2 (name, exactBuffer, loadAddress); appleFile = new SimpleText2 (name, exactBuffer, loadAddress);
break; break;
default: default:
System.out.println ("Unknown file type : " + fileType); System.out.println ("Unknown file type : " + fileType);
appleFile = new DefaultAppleFile (name, buffer); appleFile = new DefaultAppleFile (name, buffer);

View File

@ -12,38 +12,40 @@ import com.bytezone.diskbrowser.disk.FormattedDisk;
abstract class CatalogEntry implements AppleFileSource abstract class CatalogEntry implements AppleFileSource
{ {
FormattedDisk parentDisk; FormattedDisk parentDisk;
DirectoryHeader parentDirectory; DirectoryHeader parentDirectory;
String name; String name;
int storageType; int storageType;
GregorianCalendar created; GregorianCalendar created;
int version; int version;
int minVersion; int minVersion;
int access; int access;
List<DiskAddress> dataBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> dataBlocks = new ArrayList<DiskAddress> ();
Disk disk; Disk disk;
public CatalogEntry (ProdosDisk parentDisk, byte[] entryBuffer) public CatalogEntry (ProdosDisk parentDisk, byte[] entryBuffer)
{ {
this.parentDisk = parentDisk; this.parentDisk = parentDisk;
this.disk = parentDisk.getDisk (); this.disk = parentDisk.getDisk ();
name = HexFormatter.getString (entryBuffer, 1, entryBuffer[0] & 0x0F); name = HexFormatter.getString (entryBuffer, 1, entryBuffer[0] & 0x0F);
storageType = (entryBuffer[0] & 0xF0) >> 4; storageType = (entryBuffer[0] & 0xF0) >> 4;
created = HexFormatter.getAppleDate (entryBuffer, 24); created = HexFormatter.getAppleDate (entryBuffer, 24);
version = HexFormatter.intValue (entryBuffer[28]); version = HexFormatter.intValue (entryBuffer[28]);
minVersion = HexFormatter.intValue (entryBuffer[29]); minVersion = HexFormatter.intValue (entryBuffer[29]);
access = HexFormatter.intValue (entryBuffer[30]); access = HexFormatter.intValue (entryBuffer[30]);
} }
public String getUniqueName () @Override
{ public String getUniqueName ()
if (parentDirectory == null) {
return name; if (parentDirectory == null)
return parentDirectory.getUniqueName () + "/" + name; return name;
} return parentDirectory.getUniqueName () + "/" + name;
}
public FormattedDisk getFormattedDisk () @Override
{ public FormattedDisk getFormattedDisk ()
return parentDisk; {
} return parentDisk;
}
} }

View File

@ -32,7 +32,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
private boolean invalid; private boolean invalid;
public FileEntry (ProdosDisk fDisk, byte[] entryBuffer, DirectoryHeader parent, public FileEntry (ProdosDisk fDisk, byte[] entryBuffer, DirectoryHeader parent,
int parentBlock) int parentBlock)
{ {
super (fDisk, entryBuffer); super (fDisk, entryBuffer);
this.parentDirectory = parent; this.parentDirectory = parent;
@ -265,13 +265,20 @@ class FileEntry extends CatalogEntry implements ProdosConstants
file = new SimpleText (name, exactBuffer); file = new SimpleText (name, exactBuffer);
else if (HiResImage.isGif (exactBuffer)) else if (HiResImage.isGif (exactBuffer))
file = new HiResImage (name, exactBuffer); file = new HiResImage (name, exactBuffer);
else if ((endOfFile == 0x1FF8 || endOfFile == 0x1FFF || endOfFile == 0x2000 || endOfFile == 0x4000) else if ((endOfFile == 0x1FF8 || endOfFile == 0x1FFF || endOfFile == 0x2000
&& (auxType == 0x1FFF || auxType == 0x2000 || auxType == 0x4000)) || endOfFile == 0x4000)
&& (auxType == 0x1FFF || auxType == 0x2000 || auxType == 0x4000))
file = new HiResImage (name, exactBuffer); file = new HiResImage (name, exactBuffer);
else if (endOfFile == 38400 && name.startsWith ("LVL.")) else if (endOfFile == 38400 && name.startsWith ("LVL."))
file = new LodeRunner (name, exactBuffer); file = new LodeRunner (name, exactBuffer);
else else
{
file = new AssemblerProgram (name, exactBuffer, auxType); file = new AssemblerProgram (name, exactBuffer, auxType);
if (exactBuffer.length < buffer.length)
((AssemblerProgram) file)
.setExtraBuffer (buffer, exactBuffer.length,
buffer.length - exactBuffer.length);
}
break; break;
case FILE_TYPE_TEXT: case FILE_TYPE_TEXT:
assert auxType == 0; // auxType > 0 handled above assert auxType == 0; // auxType > 0 handled above
@ -288,9 +295,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
break; break;
case FILE_TYPE_DIRECTORY: case FILE_TYPE_DIRECTORY:
VolumeDirectoryHeader vdh = ((ProdosDisk) parentDisk).vdh; VolumeDirectoryHeader vdh = ((ProdosDisk) parentDisk).vdh;
file = file = new ProdosDirectory (parentDisk, name, buffer, vdh.totalBlocks,
new ProdosDirectory (parentDisk, name, buffer, vdh.totalBlocks, vdh.freeBlocks, vdh.usedBlocks);
vdh.freeBlocks, vdh.usedBlocks);
break; break;
case FILE_TYPE_APPLESOFT_BASIC_VARS: case FILE_TYPE_APPLESOFT_BASIC_VARS:
if (endOfFile == 0) if (endOfFile == 0)
@ -328,9 +334,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
default: default:
System.out.format ("Unknown file type : %02X%n", fileType); System.out.format ("Unknown file type : %02X%n", fileType);
if (fileType == 0xB3) if (fileType == 0xB3)
file = file = new DefaultAppleFile (name, exactBuffer,
new DefaultAppleFile (name, exactBuffer, "S16 Apple IIgs Application Program");
"S16 Apple IIgs Application Program");
else else
file = new DefaultAppleFile (name, exactBuffer); file = new DefaultAppleFile (name, exactBuffer);
} }
@ -370,7 +375,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
byte[] mainIndexBuffer = disk.readSector (keyPtr); byte[] mainIndexBuffer = disk.readSector (keyPtr);
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
int indexBlock = HexFormatter.intValue (mainIndexBuffer[i], mainIndexBuffer[i + 256]); int indexBlock =
HexFormatter.intValue (mainIndexBuffer[i], mainIndexBuffer[i + 256]);
if (indexBlock > 0) if (indexBlock > 0)
logicalBlock = readIndexBlock (indexBlock, addresses, buffers, logicalBlock); logicalBlock = readIndexBlock (indexBlock, addresses, buffers, logicalBlock);
else else
@ -378,7 +384,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
if (addresses.size () > 0) if (addresses.size () > 0)
{ {
byte[] tempBuffer = disk.readSectors (addresses); byte[] tempBuffer = disk.readSectors (addresses);
buffers.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ())); buffers.add (new TextBuffer (tempBuffer, auxType,
logicalBlock - addresses.size ()));
addresses.clear (); addresses.clear ();
} }
logicalBlock += 256; logicalBlock += 256;
@ -497,7 +504,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
} }
private int readIndexBlock (int indexBlock, List<DiskAddress> addresses, private int readIndexBlock (int indexBlock, List<DiskAddress> addresses,
List<TextBuffer> buffers, int logicalBlock) List<TextBuffer> buffers, int logicalBlock)
{ {
byte[] indexBuffer = disk.readSector (indexBlock); byte[] indexBuffer = disk.readSector (indexBlock);
for (int j = 0; j < 256; j++) for (int j = 0; j < 256; j++)
@ -508,7 +515,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
else if (addresses.size () > 0) else if (addresses.size () > 0)
{ {
byte[] tempBuffer = disk.readSectors (addresses); byte[] tempBuffer = disk.readSectors (addresses);
buffers.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ())); buffers
.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
addresses.clear (); addresses.clear ();
} }
logicalBlock++; logicalBlock++;
@ -549,12 +557,14 @@ class FileEntry extends CatalogEntry implements ProdosConstants
// String locked = (access == 0x01) ? "*" : " "; // String locked = (access == 0x01) ? "*" : " ";
String locked = (access == 0x00) ? "*" : " "; String locked = (access == 0x00) ? "*" : " ";
if (true) if (true)
return String.format ("%s %03d %s", ProdosConstants.fileTypes[fileType], blocksUsed, return String.format ("%s %03d %s", ProdosConstants.fileTypes[fileType],
locked) + name; blocksUsed, locked)
+ name;
String timeC = created == null ? "" : ProdosDisk.df.format (created.getTime ()); String timeC = created == null ? "" : ProdosDisk.df.format (created.getTime ());
String timeF = modified == null ? "" : ProdosDisk.df.format (modified.getTime ()); String timeF = modified == null ? "" : ProdosDisk.df.format (modified.getTime ());
return String.format ("%s %s%-30s %3d %,10d %15s %15s", return String.format ("%s %s%-30s %3d %,10d %15s %15s",
ProdosConstants.fileTypes[fileType], locked, parentDirectory.name ProdosConstants.fileTypes[fileType], locked,
+ "/" + name, blocksUsed, endOfFile, timeC, timeF); parentDirectory.name + "/" + name, blocksUsed, endOfFile, timeC,
timeF);
} }
} }