using System;
using System.IO;
namespace MatFileHandler.Tests
{
///
/// A stream which wraps another stream and forbids seeking in it.
///
internal sealed class UnseekableWriteStream : Stream
{
public UnseekableWriteStream(Stream baseStream)
{
_baseStream = baseStream;
}
private readonly Stream _baseStream;
public override bool CanRead => false;
public override bool CanSeek => false;
public override bool CanWrite => _baseStream.CanWrite;
public override long Length => _baseStream.Length;
public override long Position
{
get => throw new NotSupportedException();
set => throw new NotSupportedException();
}
public override void Flush()
{
_baseStream.Flush();
}
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
}
public override void SetLength(long value)
{
throw new NotSupportedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
_baseStream.Write(buffer, offset, count);
}
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
_baseStream.Dispose();
}
base.Dispose(disposing);
}
}
}