public override void Write (byte[] buffer, int offset, int count)
{
if (closed)
throw new ObjectDisposedException("The stream is closed");
if (buffer == null)
throw new ArgumentNullException("The buffer parameter is a null reference");
if (offset < 0)
throw new ArgumentOutOfRangeException("offset", "Non-negative number required.");
if (count < 0)
throw new ArgumentOutOfRangeException("count", "Non-negative number required.");
if ((buffer.Length - offset) < count)
throw new ArgumentException("The length of the buffer array minus the offset parameter is less than the count parameter");
if (current_position > capacity - count)
throw new NotSupportedException ("Unable to expand length of this stream beyond its capacity.");
if (fileaccess == FileAccess.Read)
throw new NotSupportedException ("Stream does not support writing.");
else {
unsafe {
// use Marshal.WriteByte since that allow us to start writing
// from the current position
for (int i = 0; i < count; i++)
Marshal.WriteByte (initial_pointer, (int) current_position++, buffer [offset + i]);
if (current_position > length)
length = current_position;
}
}
}