Example #1
0
        public UdifBuffer(Stream stream, ResourceFork resources, long sectorCount)
        {
            _stream = stream;
            _resources = resources;
            _sectorCount = sectorCount;

            _blocks = new List<CompressedBlock>();

            foreach (var resource in _resources.GetAllResources("blkx"))
            {
                _blocks.Add(((BlkxResource)resource).Block);
            }
        }
Example #2
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);
            }
        }