Example #1
0
 private void ReadVolumeDescriptor(VolumeDescriptor descriptor)
 {
     descriptor.VolFlags = ReadByte();
     ReadBytes(descriptor.SystemIdentifier, descriptor.SystemIdentifier.Length);
     ReadBytes(descriptor.VolumeIdentifier, descriptor.VolumeIdentifier.Length);
     SkeepZeros(8);
     descriptor.VolumeSpaceSize = ReadInt64();
     ReadBytes(descriptor.EscapeSequence, descriptor.EscapeSequence.Length);
     descriptor.VolumeSetSize = ReadInt32();
     descriptor.VolumeSequenceNumber = ReadInt32();
     descriptor.LogicalBlockSize = ReadInt32();
     descriptor.PathTableSize = ReadInt64();
     descriptor.LPathTableLocation = ReadInt32Le();
     descriptor.LOptionalPathTableLocation = ReadInt32Le();
     descriptor.MPathTableLocation = ReadInt32Be();
     descriptor.MOptionalPathTableLocation = ReadInt32Be();
     ReadDirRecord(descriptor.RootDirRecord);
     ReadBytes(descriptor.VolumeSetIdentifier, descriptor.VolumeSetIdentifier.Length);
     ReadBytes(descriptor.PublisherIdentifier, descriptor.PublisherIdentifier.Length);
     ReadBytes(descriptor.DataPreparerIdentifier, descriptor.DataPreparerIdentifier.Length);
     ReadBytes(descriptor.ApplicationIdentifier, descriptor.ApplicationIdentifier.Length);
     ReadBytes(descriptor.CopyrightFileIdentifier, descriptor.CopyrightFileIdentifier.Length);
     ReadBytes(descriptor.AbstractFileIdentifier, descriptor.AbstractFileIdentifier.Length);
     ReadBytes(descriptor.BibFileIdentifier, descriptor.BibFileIdentifier.Length);
     ReadDateTime(descriptor.CTime);
     ReadDateTime(descriptor.MTime);
     ReadDateTime(descriptor.ExpirationTime);
     ReadDateTime(descriptor.EffectiveTime);
     descriptor.FileStructureVersion = ReadByte();
     SkeepZeros(1);
     ReadBytes(descriptor.ApplicationUse, descriptor.ApplicationUse.Length);
     SkeepZeros(653);
 }
Example #2
0
        public override bool Open()
        {
            base.Open();

            StartPosition = (ImageReader.PRIMARY_VOLUME_SECTOR * CurrentBlockSize);
            dataBuffer = new byte[CurrentBlockSize];
            BaseStream.Seek(StartPosition, SeekOrigin.Begin);
            bool primVolDescDefined = false;
            dataBufferPosition = 0;
            _volumeDescriptor.Add(new VolumeDescriptor());
            bool exit = false;
            while (!exit)
            {
                byte[] sig = new byte[7];
                ReadBytes(sig, 7);
                byte ver = sig[6];
                if (!CheckSignature(1, SignatureCD001, sig))
                    return false;

                _version = ver;

                if (Version > 2) // version = 2 for ISO 9660:1999?
                    throw new InvalidDataException();

                switch ((VolumeDescriptorType)sig[0])
                {
                    case VolumeDescriptorType.BootRecord:
                        {
                            break;
                        }
                    case VolumeDescriptorType.PrimaryVolume:
                        {
                            if (primVolDescDefined)
                                return false;
                            primVolDescDefined = true;
                            VolumeDescriptor volDesc = _volumeDescriptor[0];
                            ReadVolumeDescriptor(volDesc);
                            for (int i = 0; i < volDesc.EscapeSequence.Length; i++)
                            {
                                // some burners write "Joliet" Escape Sequence to primary volume reset them to zero
                                volDesc.EscapeSequence[i] = 0;
                            }
                            break;
                        }
                    case VolumeDescriptorType.SupplementaryVolume:
                        {
                            VolumeDescriptor sd = new VolumeDescriptor();
                            ReadVolumeDescriptor(sd);
                            _volumeDescriptor.Add(sd);
                            break;
                        }
                    case VolumeDescriptorType.Terminator:
                    default:
                        exit = true;
                        break;
                }
            }

            if (!primVolDescDefined)
                return false;
            MainVolDescIndex = 0;
            if (!this.NoJoliet)
            {
                for (int i = _volumeDescriptor.Count - 1; i >= 0; i--)
                {
                    if (_volumeDescriptor[i].IsJoliet)
                    {
                        MainVolDescIndex = i;
                        break;
                    }
                }
            }
            if (_volumeDescriptor[MainVolDescIndex].LogicalBlockSize != ImageReader.SECTOR_SIZE)
                return false;
            _rootDirectory = _volumeDescriptor[MainVolDescIndex].RootDirRecord;
            IsoRecord root = _rootDirectory as IsoRecord;
            root.IsJoliet = IsJoliet;
            ReadDir(root, 0);
            _volumename = _volumeDescriptor[MainVolDescIndex].GetString();
            return true;
        }