private IEnumerable <ICdFile> DecodeInternal(IEnumerable <ICdSector> cdSectors) { var sectorInfos = _isoDescriptorSectorFinder .Find(cdSectors.Select(s => _isoSectorInfoDecoder.Decode(s))); var storageMediums = _isoStorageMediumDecoder.Decode(sectorInfos); foreach (var volume in storageMediums.Volumes) { var pathLba = volume.TypeLPathTableLocation; var pathTable = _isoPathTableDecoder.Decode(cdSectors.SkipWhile(cds => cds.Number != pathLba)); foreach (var path in pathTable) { var directory = _isoDirectoryTableDecoder.Decode( cdSectors.SkipWhile(cds => cds.Number != path.LocationOfExtent)); foreach (var entry in directory) { if (entry.Flags.HasFlag(IsoFileFlags.Directory)) { continue; } yield return(new CdFile(() => _isoSectorStreamFactory.Open( cdSectors.SkipWhile(cds => cds.Number != entry.LocationOfExtent), entry.DataLength)) { Name = GetPath(pathTable, entry, path), Length = entry.DataLength }); } } } }
private IEnumerable <IsoPathRecord> DecodeInternal(IEnumerable <ICdSector> sectors) { using (var stream = _isoSectorStreamFactory.Open(sectors)) { var reader = new BinaryReader(stream); while (true) { var length = reader.ReadByte(); if (length == 0) { yield break; } var eaLength = reader.ReadByte(); var lba = reader.ReadInt32(); var parent = reader.ReadUInt16(); var name = reader.ReadBytes(length); if ((length & 1) != 0) { reader.ReadByte(); } if (name.Length == 1) { if (name[0] == 0x00) { name = new byte[] { 0x2E } } ; else if (name[0] == 0x01) { name = new byte[] { 0x2E, 0x2E } } ; } yield return(new IsoPathRecord { LocationOfExtent = lba, DirectoryIdentifier = Encodings.CP437.GetString(name), ExtendedAttributeRecordLength = eaLength, ParentDirectoryNumber = parent }); } } } }
private IEnumerable <IsoDirectoryRecord> DecodeInternal(IEnumerable <ICdSector> sectors) { using (var stream = _isoSectorStreamFactory.Open(sectors)) { while (true) { var record = _isoDirectoryRecordDecoder.Decode(stream, false); if (record != null) { yield return(record); } else { yield break; } } } }