diff --git a/SabreTools.Serialization/Readers/ISO9660.cs b/SabreTools.Serialization/Readers/ISO9660.cs index 3b3e17e0..f5e125bb 100644 --- a/SabreTools.Serialization/Readers/ISO9660.cs +++ b/SabreTools.Serialization/Readers/ISO9660.cs @@ -401,11 +401,8 @@ namespace SabreTools.Serialization.Readers var groups = new List(); foreach (VolumeDescriptor vd in vdSet) { - if (vd is not BaseVolumeDescriptor bvd) - continue; - // Parse the path table group in the base volume descriptor - var pathTableGroups = ParsePathTableGroup(data, sectorLength, bvd); + var pathTableGroups = ParsePathTableGroup(data, sectorLength, vd); if (pathTableGroups.Count > 0) groups.AddRange(pathTableGroups); } @@ -424,17 +421,33 @@ namespace SabreTools.Serialization.Readers /// Number of bytes in a logical sector (usually 2048) /// Primary/Supplementary/Enhanced Volume Descriptor pointing to path table(s) /// Filled list of PathTableGroup on success, null on error - public static List ParsePathTableGroup(Stream data, short sectorLength, BaseVolumeDescriptor vd) + public static List ParsePathTableGroup(Stream data, short sectorLength, VolumeDescriptor vd) { + int sizeL, sizeB, locationL, locationL2, locationM, locationM2; + if (vd is PrimaryVolumeDescriptor pvd) + { + sizeL = pvd.PathTableSize.LittleEndian; + sizeB = pvd.PathTableSize.BigEndian; + locationL = pvd.PathTableLocationL; + locationL2 = pvd.OptionalPathTableLocationL; + locationM = pvd.PathTableLocationM; + locationM2 = pvd.OptionalPathTableLocationM; + } + else if (vd is SupplementaryVolumeDescriptor svd) + { + sizeL = svd.PathTableSize.LittleEndian; + sizeB = svd.PathTableSize.BigEndian; + locationL = svd.PathTableLocationL; + locationL2 = svd.OptionalPathTableLocationL; + locationM = svd.PathTableLocationM; + locationM2 = svd.OptionalPathTableLocationM; + } + else + { + return []; + } + var groups = new List(); - - int sizeL = vd.PathTableSize.LittleEndian; - int sizeB = vd.PathTableSize.BigEndian; - int locationL = vd.PathTableLocationL; - int locationL2 = vd.OptionalPathTableLocationL; - int locationM = vd.PathTableLocationM; - int locationM2 = vd.OptionalPathTableLocationM; - short blockLength = vd.GetLogicalBlockSize(sectorLength); var groupL = new PathTableGroup(); @@ -575,14 +588,19 @@ namespace SabreTools.Serialization.Readers var directories = new Dictionary(); foreach (VolumeDescriptor vd in vdSet) { - if (vd is not BaseVolumeDescriptor bvd) + DirectoryRecord rootDirectoryRecord; + if (vd is PrimaryVolumeDescriptor pvd) + rootDirectoryRecord = pvd.RootDirectoryRecord; + else if (vd is SupplementaryVolumeDescriptor svd) + rootDirectoryRecord = svd.RootDirectoryRecord; + else continue; // Determine logical block size - short blockLength = bvd.GetLogicalBlockSize(sectorLength); + short blockLength = vd.GetLogicalBlockSize(sectorLength); // Parse the root directory pointed to from the base volume descriptor - var descriptors = ParseDirectory(data, sectorLength, blockLength, bvd.RootDirectoryRecord, false); + var descriptors = ParseDirectory(data, sectorLength, blockLength, rootDirectoryRecord, false); if (descriptors == null || descriptors.Count == 0) continue;