Example #1
0
        public SparseExtent(string path) : base(path)
        {
            m_file = new RawDiskImage(path, VirtualMachineDisk.BytesPerDiskSector);
            byte[] headerBytes = m_file.ReadSector(0);
            m_header = new SparseExtentHeader(headerBytes);

            if (m_header.IsValidAndSupported)
            {
                if (m_header.DescriptorOffset > 0)
                {
                    byte[]        descriptorBytes = m_file.ReadSectors((long)m_header.DescriptorOffset, (int)m_header.DescriptorSize);
                    string        text            = ASCIIEncoding.ASCII.GetString(descriptorBytes);
                    List <string> lines           = VirtualMachineDiskDescriptor.GetLines(text);
                    m_descriptor = new VirtualMachineDiskDescriptor(lines);
                }
            }
        }
Example #2
0
        public SparseExtent(string path) : base(path)
        {
            m_file = new RawDiskImage(path, VirtualMachineDisk.BytesPerDiskSector);
            byte[] headerBytes = m_file.ReadSector(0);
            m_header = new SparseExtentHeader(headerBytes);
            if (!m_header.IsSupported)
            {
                throw new NotSupportedException("Sparse extent header version is not supported");
            }

            if (m_header.CompressionAlgirithm != SparseExtentCompression.None)
            {
                throw new NotSupportedException("Sparse extent compression is not supported");
            }

            if (m_header.DescriptorOffset > 0)
            {
                byte[]        descriptorBytes = m_file.ReadSectors((long)m_header.DescriptorOffset, (int)m_header.DescriptorSize);
                string        text            = ASCIIEncoding.ASCII.GetString(descriptorBytes);
                List <string> lines           = VirtualMachineDiskDescriptor.GetLines(text);
                m_descriptor = new VirtualMachineDiskDescriptor(lines);
            }
        }