void WriteHeader(bool notify) { using (LockWrite()) { m_Fs.Seek(0, SeekOrigin.Begin); TransactionUtils.SerializeInto(m_Header, m_HeaderBuffer, 0); m_Fs.Write(m_HeaderBuffer, 0, m_HeaderBuffer.Length); if (notify && !m_DelayedSync) { Sync(); } } }
void Create(int stringCount, int averageStringLength = DefaultAverageStringSize) { var header = new PropertyStringTableHeader(); header.version = Version; header.count = 0; header.symbolSlots = Math.Max(stringCount * HashFactor, 1); var bytesPerString = GetStringByteSize(averageStringLength); header.allocatedStringBytes = stringCount * bytesPerString; header.usedStringBytes = StringLengthByteSize; var buffer = new byte[Marshal.SizeOf <PropertyStringTableHeader>() + GetSymbolsByteSize(header.symbolSlots) + header.allocatedStringBytes]; TransactionUtils.SerializeInto(header, buffer, 0); using (var fs = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete)) fs.Write(buffer, 0, buffer.Length); }
void WriteInt32(int value) { TransactionUtils.SerializeInto(value, m_SymbolBuffer, 0); m_Fs.Write(m_SymbolBuffer, 0, m_SymbolBuffer.Length); }