コード例 #1
0
        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
                        });
                    }
                }
            }
        }
コード例 #2
0
        public IsoStorageMedium Decode(IEnumerable <IsoSectorInfo> sectors)
        {
            var result = new IsoStorageMedium
            {
                BootRecords = new List <IsoBootRecord>(),
                Volumes     = new List <IsoVolume>()
            };

            var descriptorSectors = _isoDescriptorSectorFinder.Find(sectors).ToList();

            var bootDescriptors         = descriptorSectors.Where(s => s.UserData[0] == 0x00).ToList();
            var primaryVolumeDescriptor = descriptorSectors.Single(s => s.UserData[0] == 0x01);

//            var supplementaryVolumeDescriptors = descriptorSectors.Where(s => s.UserData[0] == 0x02).ToList();
//            var partitionDescriptors = descriptorSectors.Where(s => s.UserData[0] == 0x03).ToList();

            foreach (var bootDescriptor in bootDescriptors)
            {
                result.BootRecords.Add(_isoBootRecordDecoder.Decode(bootDescriptor.UserData));
            }

            var primaryVolume = _isoPrimaryVolumeDescriptorDecoder.Decode(primaryVolumeDescriptor.UserData);

            result.Volumes.Add(primaryVolume);

            return(result);
        }