dmolony-DiskBrowser/src/com/bytezone/diskbrowser/applefile/FinderData.java

72 lines
2.0 KiB
Java
Raw Normal View History

2020-04-03 07:38:14 +00:00
package com.bytezone.diskbrowser.applefile;
import com.bytezone.diskbrowser.utilities.HexFormatter;
// -----------------------------------------------------------------------------------//
public class FinderData extends AbstractFile
// -----------------------------------------------------------------------------------//
{
2020-05-15 01:14:01 +00:00
int version = buffer[0];
2020-04-03 07:38:14 +00:00
// ---------------------------------------------------------------------------------//
public FinderData (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
{
super (name, buffer);
}
// ---------------------------------------------------------------------------------//
@Override
public String getText ()
// ---------------------------------------------------------------------------------//
{
StringBuilder text = new StringBuilder ();
text.append ("Name : " + name + "\n\n");
2020-05-15 01:14:01 +00:00
text.append ("\n\n");
if (version == 1)
2020-04-08 02:17:08 +00:00
{
2020-05-15 01:14:01 +00:00
int ptr = 16;
text.append (HexFormatter.getHexString (buffer, 0, ptr));
text.append ("\n\n");
while (buffer[ptr] != 0)
{
String line = HexFormatter.getHexString (buffer, ptr, 6);
text.append (line + " ");
2020-04-08 02:17:08 +00:00
2020-05-15 01:14:01 +00:00
String name = HexFormatter.getPascalString (buffer, ptr + 6);
text.append (name + "\n");
2020-04-03 07:38:14 +00:00
2020-05-15 01:14:01 +00:00
ptr += 22;
}
}
else if (version == 2)
2020-04-03 07:38:14 +00:00
{
2020-05-15 01:14:01 +00:00
int totFiles = buffer[34];
int ptr = 42;
text.append (HexFormatter.format (buffer, 0, ptr));
text.append ("\n\n");
for (int i = 0; i < totFiles; i++)
{
String line = HexFormatter.getHexString (buffer, ptr, 8);
text.append (line + " ");
2020-04-03 07:38:14 +00:00
2020-05-15 01:14:01 +00:00
ptr += 8;
String name = HexFormatter.getPascalString (buffer, ptr);
text.append (String.format ("%-20s ", name));
2020-04-03 07:38:14 +00:00
2020-05-15 01:14:01 +00:00
ptr += name.length () + 1;
text.append (String.format ("%02X%n", buffer[ptr++]));
}
2020-04-03 07:38:14 +00:00
}
2020-05-15 01:14:01 +00:00
if (text.length () > 0)
text.deleteCharAt (text.length () - 1);
2020-04-03 07:38:14 +00:00
return text.toString ();
}
}