Implement CD-i path table traversal

This commit is contained in:
2019-07-31 05:19:18 +01:00
parent bc8dd3a486
commit 738dcdbdba
3 changed files with 99 additions and 62 deletions

View File

@@ -866,7 +866,44 @@ namespace DiscImageChef.Filesystems.ISO9660
return tableEntries.ToArray();
}
DecodedDirectoryEntry[] GetSubdirsFromCdiPathTable(string path) => throw new NotImplementedException();
DecodedDirectoryEntry[] GetSubdirsFromCdiPathTable(string path)
{
PathTableEntryInternal[] tableEntries = GetPathTableEntries(path);
List<DecodedDirectoryEntry> entries = new List<DecodedDirectoryEntry>();
foreach(PathTableEntryInternal tEntry in tableEntries)
{
byte[] sector = image.ReadSector(tEntry.Extent);
CdiDirectoryRecord record =
Marshal.ByteArrayToStructureBigEndian<CdiDirectoryRecord>(sector, 0,
Marshal.SizeOf<CdiDirectoryRecord>());
if(record.length == 0) break;
DecodedDirectoryEntry entry = new DecodedDirectoryEntry
{
Extent = record.size == 0 ? 0 : record.start_lbn,
Size = record.size,
Filename = tEntry.Name,
VolumeSequenceNumber = record.volume_sequence_number,
Timestamp = DecodeHighSierraDateTime(record.date)
};
if(record.flags.HasFlag(CdiFileFlags.Hidden)) entry.Flags |= FileFlags.Hidden;
entry.CdiSystemArea =
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(sector,
record.name_len +
Marshal.SizeOf<CdiDirectoryRecord>(),
Marshal.SizeOf<CdiSystemArea>());
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory))
entry.Flags |= FileFlags.Directory;
entries.Add(entry);
}
return entries.ToArray();
}
DecodedDirectoryEntry[] GetSubdirsFromIsoPathTable(string path)
{