Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the DiskImageFile class.
        /// </summary>
        /// <param name="stream">The stream to read</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        public DiskImageFile(Stream stream, Ownership ownsStream)
        {
            _udifHeader = new UdifResourceFile();
            _stream     = stream;
            _ownsStream = ownsStream;

            stream.Position = stream.Length - _udifHeader.Size;
            byte[] data = Utilities.ReadFully(stream, _udifHeader.Size);

            _udifHeader.ReadFrom(data, 0);

            if (_udifHeader.SignatureValid)
            {
                stream.Position = (long)_udifHeader.XmlOffset;
                byte[] xmlData = Utilities.ReadFully(stream, (int)_udifHeader.XmlLength);
                var    plist   = Plist.Parse(new MemoryStream(xmlData));

                _resources = ResourceFork.FromPlist(plist);
                _buffer    = new UdifBuffer(stream, _resources, _udifHeader.SectorCount);
            }
        }
        /// <summary>
        /// Initializes a new instance of the DiskImageFile class.
        /// </summary>
        /// <param name="stream">The stream to read</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        public DiskImageFile(Stream stream, Ownership ownsStream)
        {
            _udifHeader = new UdifResourceFile();
            _stream = stream;
            _ownsStream = ownsStream;

            stream.Position = stream.Length - _udifHeader.Size;
            byte[] data = Utilities.ReadFully(stream, _udifHeader.Size);

            _udifHeader.ReadFrom(data, 0);

            if (_udifHeader.SignatureValid)
            {
                stream.Position = (long)_udifHeader.XmlOffset;
                byte[] xmlData = Utilities.ReadFully(stream, (int)_udifHeader.XmlLength);
                var plist = Plist.Parse(new MemoryStream(xmlData));

                _resources = ResourceFork.FromPlist(plist);
                _buffer = new UdifBuffer(stream, _resources, _udifHeader.SectorCount);
            }
        }