public int Read(byte[] buffer, int offset)
 {
     FileInfo = Utilities.BytesToString(buffer, offset + 0, 64).TrimEnd(new char[] { '\0' });
     Signature = Utilities.ToUInt32LittleEndian(buffer, offset + 64);
     Version = new FileVersion(Utilities.ToUInt32LittleEndian(buffer, offset + 68));
     return Size;
 }
示例#2
0
        public void Read(FileVersion version, Stream s)
        {
            int headerSize;

            _fileVersion = version;

            // Determine header size...
            if (version.Major == 0)
            {
                headerSize = 348;
            }
            else
            {
                long savedPos = s.Position;
                headerSize = Utilities.ToInt32LittleEndian(Utilities.ReadFully(s, 4), 0);
                s.Position = savedPos;
            }

            byte[] buffer = Utilities.ReadFully(s, headerSize);
            Read(version, buffer, 0);
        }
示例#3
0
        public int Read(FileVersion version, byte[] buffer, int offset)
        {
            if (version.Major == 0)
            {
                ImageType = (ImageType)Utilities.ToUInt32LittleEndian(buffer, offset + 0);
                Flags = (ImageFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 4);
                Comment = Utilities.BytesToString(buffer, offset + 8, 256).TrimEnd(new char[] { '\0' });
                LegacyGeometry = new GeometryRecord();
                LegacyGeometry.Read(buffer, offset + 264);
                DiskSize = Utilities.ToInt64LittleEndian(buffer, offset + 280);
                BlockSize = Utilities.ToInt32LittleEndian(buffer, offset + 288);
                BlockCount = Utilities.ToInt32LittleEndian(buffer, offset + 292);
                BlocksAllocated = Utilities.ToInt32LittleEndian(buffer, offset + 296);
                UniqueId = Utilities.ToGuidLittleEndian(buffer, offset + 300);
                ModificationId = Utilities.ToGuidLittleEndian(buffer, offset + 316);
                ParentId = Utilities.ToGuidLittleEndian(buffer, offset + 332);
                HeaderSize = 348;
                BlocksOffset = HeaderSize + PreHeaderRecord.Size;
                DataOffset = (uint)(BlocksOffset + (BlockCount * 4));
                BlockExtraSize = 0;
                ParentModificationId = Guid.Empty;
            }
            else if (version.Major == 1 && version.Minor == 1)
            {
                HeaderSize = Utilities.ToUInt32LittleEndian(buffer, offset + 0);
                ImageType = (ImageType)Utilities.ToUInt32LittleEndian(buffer, offset + 4);
                Flags = (ImageFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 8);
                Comment = Utilities.BytesToString(buffer, offset + 12, 256).TrimEnd(new char[] { '\0' });
                BlocksOffset = Utilities.ToUInt32LittleEndian(buffer, offset + 268);
                DataOffset = Utilities.ToUInt32LittleEndian(buffer, offset + 272);
                LegacyGeometry = new GeometryRecord();
                LegacyGeometry.Read(buffer, offset + 276);
                DiskSize = Utilities.ToInt64LittleEndian(buffer, offset + 296);
                BlockSize = Utilities.ToInt32LittleEndian(buffer, offset + 304);
                BlockExtraSize = Utilities.ToInt32LittleEndian(buffer, offset + 308);
                BlockCount = Utilities.ToInt32LittleEndian(buffer, offset + 312);
                BlocksAllocated = Utilities.ToInt32LittleEndian(buffer, offset + 316);
                UniqueId = Utilities.ToGuidLittleEndian(buffer, offset + 320);
                ModificationId = Utilities.ToGuidLittleEndian(buffer, offset + 336);
                ParentId = Utilities.ToGuidLittleEndian(buffer, offset + 352);
                ParentModificationId = Utilities.ToGuidLittleEndian(buffer, offset + 368);

                if (HeaderSize > 384)
                {
                    LChsGeometry = new GeometryRecord();
                    LChsGeometry.Read(buffer, offset + 384);
                }
            }
            else
            {
                throw new IOException("Unrecognized file version: " + version);
            }

            return (int)HeaderSize;
        }