2020-02-09 13:13:33 +00:00
|
|
|
package com.bytezone.diskbrowser.prodos;
|
|
|
|
|
2021-04-17 07:33:27 +00:00
|
|
|
import java.time.LocalDateTime;
|
2020-02-09 13:13:33 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
|
|
|
import com.bytezone.diskbrowser.disk.Disk;
|
|
|
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
|
|
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
|
|
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
2021-04-17 07:33:27 +00:00
|
|
|
import com.bytezone.diskbrowser.utilities.Utility;
|
2020-02-09 13:13:33 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------//
|
|
|
|
abstract class CatalogEntry implements AppleFileSource
|
|
|
|
// -----------------------------------------------------------------------------------//
|
|
|
|
{
|
2021-05-03 22:50:30 +00:00
|
|
|
static String[] storageTypes = { "Del", "Sdl", "Sap", "Tre", "Pas", "Ext", "", "", "",
|
|
|
|
"", "", "", "", "DIR", "SDH", "VDH" };
|
2021-04-25 02:08:09 +00:00
|
|
|
Disk disk;
|
2020-02-09 13:13:33 +00:00
|
|
|
ProdosDisk parentDisk;
|
2021-04-25 02:08:09 +00:00
|
|
|
|
2021-04-27 11:26:09 +00:00
|
|
|
int blockNo;
|
|
|
|
int entryNo;
|
|
|
|
|
2020-02-09 13:13:33 +00:00
|
|
|
String name;
|
|
|
|
int storageType;
|
2021-04-25 02:08:09 +00:00
|
|
|
|
2021-04-17 07:33:27 +00:00
|
|
|
LocalDateTime created;
|
2020-02-09 13:13:33 +00:00
|
|
|
int version;
|
|
|
|
int minVersion;
|
|
|
|
int access;
|
2021-04-25 02:08:09 +00:00
|
|
|
|
2020-02-09 13:13:33 +00:00
|
|
|
List<DiskAddress> dataBlocks = new ArrayList<> ();
|
2021-04-25 02:08:09 +00:00
|
|
|
DirectoryHeader parentDirectory;
|
2020-02-09 13:13:33 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------//
|
2021-04-27 11:26:09 +00:00
|
|
|
CatalogEntry (ProdosDisk parentDisk, byte[] entryBuffer, int blockNo, int entryNo)
|
2020-02-09 13:13:33 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
this.parentDisk = parentDisk;
|
|
|
|
this.disk = parentDisk.getDisk ();
|
2021-04-27 11:26:09 +00:00
|
|
|
this.blockNo = blockNo;
|
|
|
|
this.entryNo = entryNo;
|
2021-04-25 02:08:09 +00:00
|
|
|
|
2020-02-09 13:13:33 +00:00
|
|
|
name = HexFormatter.getString (entryBuffer, 1, entryBuffer[0] & 0x0F);
|
|
|
|
storageType = (entryBuffer[0] & 0xF0) >> 4;
|
2021-04-25 02:08:09 +00:00
|
|
|
|
2021-04-17 07:33:27 +00:00
|
|
|
created = Utility.getAppleDate (entryBuffer, 24);
|
2020-02-09 13:13:33 +00:00
|
|
|
version = entryBuffer[28] & 0xFF;
|
|
|
|
minVersion = entryBuffer[29] & 0xFF;
|
|
|
|
access = entryBuffer[30] & 0xFF;
|
|
|
|
}
|
|
|
|
|
2021-04-27 11:26:09 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
public String getName ()
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
public String getText ()
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
2021-05-01 23:38:24 +00:00
|
|
|
return String.format ("%04X:%02X %-15s %s", blockNo, entryNo, name,
|
|
|
|
storageTypes[storageType]);
|
2021-04-27 11:26:09 +00:00
|
|
|
}
|
|
|
|
|
2020-02-09 13:13:33 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
@Override
|
|
|
|
public String getUniqueName ()
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
if (parentDirectory == null)
|
|
|
|
return name;
|
|
|
|
return parentDirectory.getUniqueName () + "/" + name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
@Override
|
|
|
|
public FormattedDisk getFormattedDisk ()
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
return parentDisk;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
@Override
|
|
|
|
public boolean contains (DiskAddress da)
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
2021-04-25 02:08:09 +00:00
|
|
|
for (DiskAddress diskAddress : dataBlocks)
|
|
|
|
if (diskAddress.matches (da))
|
2020-02-09 13:13:33 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
@Override
|
|
|
|
public String toString ()
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
StringBuilder text = new StringBuilder ();
|
|
|
|
|
|
|
|
text.append (String.format ("Name .......... %s%n", name));
|
|
|
|
text.append (String.format ("Storage type... %02X%n", storageType));
|
|
|
|
text.append (String.format ("Created ....... %s%n",
|
2021-04-17 07:33:27 +00:00
|
|
|
created == null ? "" : created.format (ProdosDisk.df)));
|
2020-02-09 13:13:33 +00:00
|
|
|
text.append (String.format ("Version ....... %d%n", version));
|
|
|
|
|
|
|
|
return text.toString ();
|
|
|
|
}
|
2015-06-01 09:35:51 +00:00
|
|
|
}
|