Exemplo n.º 1
0
        public async Task WriteToFileBufferAsync(Stream fileStream, InMemoryBinaryWriter memoryBuffer)
        {
            // The values are each individually checksummed, so we don't need to separately checksum the block being written.

            // Write to disk.
            await memoryBuffer.WriteAsync(fileStream).ConfigureAwait(false);

            // Reset the memory buffer to be able to re-use it.
            memoryBuffer.BaseStream.Position = 0;
        }
Exemplo n.º 2
0
        internal async Task FlushMemoryBufferAsync(Stream fileStream, InMemoryBinaryWriter memoryBuffer)
        {
            //// Checksum the chunk.
            //ulong checksum = memoryBuffer.GetChecksum();
            //memoryBuffer.Write(checksum);

            // Write to disk.
            await memoryBuffer.WriteAsync(fileStream).ConfigureAwait(false);

            // Reset the memory buffer.
            memoryBuffer.BaseStream.Position = 0;
        }
Exemplo n.º 3
0
        private static async Task FlushMemoryBufferAsync(Stream fileStream, InMemoryBinaryWriter memoryBuffer)
        {
            // Write the chunk length at the beginning of the stream.
            var chunkSize = checked ((int)memoryBuffer.BaseStream.Position);

            memoryBuffer.BaseStream.Position = 0;
            var propertyChunkMetadata = new PropertyChunkMetadata(chunkSize);

            propertyChunkMetadata.Write(memoryBuffer);

            // Move to end.
            memoryBuffer.BaseStream.Position = chunkSize;

            // Checksum the chunk.
            var checksum = memoryBuffer.GetChecksum();

            memoryBuffer.Write(checksum);

            // Write to disk.
            await memoryBuffer.WriteAsync(fileStream).ConfigureAwait(false);

            // Reset the memory buffer.
            memoryBuffer.BaseStream.Position = 0;
        }