public byte[] GetBytes(int bytesPerIndexRecord, bool applyUsaProtection) { int strideCount = bytesPerIndexRecord / MultiSectorHelper.BytesPerStride; ushort updateSequenceArraySize = (ushort)(1 + strideCount); MultiSectorHeader multiSectorHeader = new MultiSectorHeader(ValidSignature, UpdateSequenceArrayOffset, updateSequenceArraySize); int updateSequenceArrayPaddedLength = (int)Math.Ceiling((double)(updateSequenceArraySize * 2) / 8) * 8; m_indexHeader.EntriesOffset = (uint)(IndexHeader.Length + updateSequenceArrayPaddedLength); m_indexHeader.TotalLength = (uint)(IndexHeader.Length + updateSequenceArrayPaddedLength + IndexEntry.GetLength(IndexEntries)); m_indexHeader.AllocatedLength = (uint)(bytesPerIndexRecord - IndexHeaderOffset); int length = applyUsaProtection ? bytesPerIndexRecord : GetNumberOfBytesInUse(bytesPerIndexRecord); byte[] buffer = new byte[length]; multiSectorHeader.WriteBytes(buffer, 0x00); LittleEndianWriter.WriteUInt64(buffer, 0x08, LogFileSequenceNumber); LittleEndianWriter.WriteUInt64(buffer, 0x10, (ulong)RecordVBN); m_indexHeader.WriteBytes(buffer, 0x18); LittleEndianWriter.WriteUInt16(buffer, UpdateSequenceArrayOffset, UpdateSequenceNumber); IndexEntry.WriteIndexEntries(buffer, UpdateSequenceArrayOffset + updateSequenceArrayPaddedLength, IndexEntries); if (applyUsaProtection) { MultiSectorHelper.ApplyUsaProtection(buffer, 0); } return(buffer); }
public byte[] GetBytes(int bytesPerIndexRecord) { int strideCount = bytesPerIndexRecord / MultiSectorHelper.BytesPerStride; ushort updateSequenceArraySize = (ushort)(1 + strideCount); MultiSectorHeader multiSectorHeader = new MultiSectorHeader(ValidSignature, UpdateSequenceArrayOffset, updateSequenceArraySize); int updateSequenceArrayPaddedLength = (int)Math.Ceiling((double)(updateSequenceArraySize * 2) / 8) * 8; m_indexHeader.EntriesOffset = (uint)(IndexHeader.Length + updateSequenceArrayPaddedLength); m_indexHeader.TotalLength = (uint)(IndexHeader.Length + updateSequenceArrayPaddedLength + IndexEntry.GetLength(IndexEntries)); m_indexHeader.AllocatedLength = (uint)(bytesPerIndexRecord - IndexHeaderOffset); byte[] buffer = new byte[bytesPerIndexRecord]; multiSectorHeader.WriteBytes(buffer, 0x00); LittleEndianWriter.WriteUInt64(buffer, 0x08, LogFileSequenceNumber); LittleEndianWriter.WriteUInt64(buffer, 0x10, (ulong)RecordVBN); m_indexHeader.WriteBytes(buffer, 0x18); IndexEntry.WriteIndexEntries(buffer, UpdateSequenceArrayOffset + updateSequenceArrayPaddedLength, IndexEntries); // Write UpdateSequenceNumber and UpdateSequenceReplacementData List <byte[]> updateSequenceReplacementData = MultiSectorHelper.EncodeSegmentBuffer(buffer, 0, bytesPerIndexRecord, UpdateSequenceNumber); MultiSectorHelper.WriteUpdateSequenceArray(buffer, UpdateSequenceArrayOffset, updateSequenceArraySize, UpdateSequenceNumber, updateSequenceReplacementData); return(buffer); }
public override byte[] GetBytes() { this.Data = new byte[this.DataLength]; m_indexHeader.EntriesOffset = IndexHeader.Length; m_indexHeader.TotalLength = (uint)this.Data.Length - IndexHeaderOffset; m_indexHeader.AllocatedLength = (uint)this.Data.Length - IndexHeaderOffset; LittleEndianWriter.WriteUInt32(this.Data, 0x00, (uint)IndexedAttributeType); LittleEndianWriter.WriteUInt32(this.Data, 0x04, (uint)CollationRule); LittleEndianWriter.WriteUInt32(this.Data, 0x08, (uint)BytesPerIndexRecord); ByteWriter.WriteByte(this.Data, 0x0C, BlocksPerIndexRecord); m_indexHeader.WriteBytes(this.Data, 0x10); IndexEntry.WriteIndexEntries(this.Data, IndexHeaderOffset + IndexHeader.Length, IndexEntries); return(base.GetBytes()); }