@@ -401,11 +401,8 @@ public static VolumeDescriptor[] ParseVolumeDescriptorSet(Stream data, short sec
401401 var groups = new List < PathTableGroup > ( ) ;
402402 foreach ( VolumeDescriptor vd in vdSet )
403403 {
404- if ( vd is not BaseVolumeDescriptor bvd )
405- continue ;
406-
407404 // Parse the path table group in the base volume descriptor
408- var pathTableGroups = ParsePathTableGroup ( data , sectorLength , bvd ) ;
405+ var pathTableGroups = ParsePathTableGroup ( data , sectorLength , vd ) ;
409406 if ( pathTableGroups . Count > 0 )
410407 groups . AddRange ( pathTableGroups ) ;
411408 }
@@ -424,17 +421,33 @@ public static VolumeDescriptor[] ParseVolumeDescriptorSet(Stream data, short sec
424421 /// <param name="sectorLength">Number of bytes in a logical sector (usually 2048)</param>
425422 /// <param name="vd">Primary/Supplementary/Enhanced Volume Descriptor pointing to path table(s)</param>
426423 /// <returns>Filled list of PathTableGroup on success, null on error</returns>
427- public static List < PathTableGroup > ParsePathTableGroup ( Stream data , short sectorLength , BaseVolumeDescriptor vd )
424+ public static List < PathTableGroup > ParsePathTableGroup ( Stream data , short sectorLength , VolumeDescriptor vd )
428425 {
429- var groups = new List < PathTableGroup > ( ) ;
430-
431- int sizeL = vd . PathTableSize . LittleEndian ;
432- int sizeB = vd . PathTableSize . BigEndian ;
433- int locationL = vd . PathTableLocationL ;
434- int locationL2 = vd . OptionalPathTableLocationL ;
435- int locationM = vd . PathTableLocationM ;
436- int locationM2 = vd . OptionalPathTableLocationM ;
426+ int sizeL , sizeB , locationL , locationL2 , locationM , locationM2 ;
427+ if ( vd is PrimaryVolumeDescriptor pvd )
428+ {
429+ sizeL = pvd . PathTableSize . LittleEndian ;
430+ sizeB = pvd . PathTableSize . BigEndian ;
431+ locationL = pvd . PathTableLocationL ;
432+ locationL2 = pvd . OptionalPathTableLocationL ;
433+ locationM = pvd . PathTableLocationM ;
434+ locationM2 = pvd . OptionalPathTableLocationM ;
435+ }
436+ else if ( vd is SupplementaryVolumeDescriptor svd )
437+ {
438+ sizeL = svd . PathTableSize . LittleEndian ;
439+ sizeB = svd . PathTableSize . BigEndian ;
440+ locationL = svd . PathTableLocationL ;
441+ locationL2 = svd . OptionalPathTableLocationL ;
442+ locationM = svd . PathTableLocationM ;
443+ locationM2 = svd . OptionalPathTableLocationM ;
444+ }
445+ else
446+ {
447+ return [ ] ;
448+ }
437449
450+ var groups = new List < PathTableGroup > ( ) ;
438451 short blockLength = vd . GetLogicalBlockSize ( sectorLength ) ;
439452
440453 var groupL = new PathTableGroup ( ) ;
@@ -575,14 +588,19 @@ public static List<PathTableGroup> ParsePathTableGroup(Stream data, short sector
575588 var directories = new Dictionary < int , FileExtent > ( ) ;
576589 foreach ( VolumeDescriptor vd in vdSet )
577590 {
578- if ( vd is not BaseVolumeDescriptor bvd )
591+ DirectoryRecord rootDirectoryRecord ;
592+ if ( vd is PrimaryVolumeDescriptor pvd )
593+ rootDirectoryRecord = pvd . RootDirectoryRecord ;
594+ else if ( vd is SupplementaryVolumeDescriptor svd )
595+ rootDirectoryRecord = svd . RootDirectoryRecord ;
596+ else
579597 continue ;
580598
581599 // Determine logical block size
582- short blockLength = bvd . GetLogicalBlockSize ( sectorLength ) ;
600+ short blockLength = vd . GetLogicalBlockSize ( sectorLength ) ;
583601
584602 // Parse the root directory pointed to from the base volume descriptor
585- var descriptors = ParseDirectory ( data , sectorLength , blockLength , bvd . RootDirectoryRecord , false ) ;
603+ var descriptors = ParseDirectory ( data , sectorLength , blockLength , rootDirectoryRecord , false ) ;
586604 if ( descriptors == null || descriptors . Count == 0 )
587605 continue ;
588606
0 commit comments