Ejemplo n.º 1
0
        /// <summary>
        /// Reads a primary volume descriptor from a stream.
        /// </summary>
        /// <param name="stream">Stream to read the primary volume descriptor from.</param>
        /// <returns>Primary volume descriptor read from the stream.</returns>
        public static PrimaryVolumeDescriptor Read(Stream stream)
        {
            var reader = new BinaryReader(stream);

            if (reader.ReadByte() != 0x01)
            {
                return(null);
            }
            if (ReadAsciiString(reader, 5) != "CD001")
            {
                throw new InvalidDataException("Not a primary volume descriptor.");
            }

            reader.ReadByte(); // Version: 0x01
            reader.ReadByte(); // Unused

            var pvd = new PrimaryVolumeDescriptor();

            pvd.SystemIdentifier = ReadAsciiString(reader, 32);
            pvd.VolumeIdentifier = ReadAsciiString(reader, 32);
            stream.Seek(8, SeekOrigin.Current);

            pvd.VolumeSpaceSize = reader.ReadUInt32();
            stream.Seek(36, SeekOrigin.Current);

            pvd.VolumeSetSize = reader.ReadUInt16();
            stream.Seek(2, SeekOrigin.Current);

            pvd.VolumeSequenceNumber = reader.ReadUInt16();
            stream.Seek(2, SeekOrigin.Current);

            pvd.LogicalBlockSize = reader.ReadUInt16();
            stream.Seek(2, SeekOrigin.Current);

            pvd.PathTableSize = reader.ReadUInt32();
            stream.Seek(4, SeekOrigin.Current);

            pvd.PathTableLocation         = reader.ReadUInt32();
            pvd.OptionalPathTableLocation = reader.ReadUInt32();
            stream.Seek(8, SeekOrigin.Current);

            pvd.RootDirectoryEntry          = DirectoryEntry.Read(reader);
            pvd.VolumeSetIdentifier         = ReadAsciiString(reader, 128);
            pvd.PublisherIdentifier         = ReadAsciiString(reader, 128);
            pvd.DataPreparerIdentifier      = ReadAsciiString(reader, 128);
            pvd.ApplicationIdentifier       = ReadAsciiString(reader, 128);
            pvd.CopyrightFileIdentifier     = ReadAsciiString(reader, 38);
            pvd.AbstractFileIdentifier      = ReadAsciiString(reader, 36);
            pvd.BibliographicFileIdentifier = ReadAsciiString(reader, 37);

            pvd.VolumeCreationDate     = ReadDate(reader);
            pvd.VolumeModificationDate = ReadDate(reader);
            pvd.VolumeExpirationDate   = ReadDate(reader);
            pvd.VolumeEffectiveDate    = ReadDate(reader);

            return(pvd);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Iso9660Disc"/> class.
        /// </summary>
        /// <param name="rawDisc">A stream backed by the raw disc.</param>
        /// <param name="sectorSize">The size of a sector on the disc.</param>
        public Iso9660Disc(Stream rawDisc, int sectorSize)
        {
            if (rawDisc == null)
            {
                throw new ArgumentNullException("rawDisc");
            }

            this.rawDisc     = rawDisc;
            rawDisc.Position = 16 * sectorSize;

            this.pvd = PrimaryVolumeDescriptor.Read(rawDisc);

            this.initializeTask = Task.Factory.StartNew(Initialize);
        }