wabbajack/Wabbajack.Common/SplittingStream.cs

71 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.IO;
namespace Wabbajack.Common
{
public class SplittingStream : Stream
{
2019-09-14 04:35:42 +00:00
private readonly Stream _a;
private readonly Stream _b;
2019-11-21 15:49:14 +00:00
private readonly bool _leaveAOpen;
private readonly bool _leaveBOpen;
2019-09-14 04:35:42 +00:00
2019-11-21 15:49:14 +00:00
public SplittingStream(Stream a, bool leaveAOpen, Stream b, bool leaveBOpen)
2019-09-14 04:35:42 +00:00
{
_a = a;
_b = b;
2019-11-21 15:49:14 +00:00
_leaveAOpen = leaveAOpen;
_leaveBOpen = leaveBOpen;
2019-09-14 04:35:42 +00:00
}
public override bool CanRead => false;
public override bool CanSeek => false;
public override bool CanWrite => true;
public override long Length => throw new NotImplementedException();
2019-09-14 04:35:42 +00:00
public override long Position
{
2019-09-14 04:35:42 +00:00
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public override void Flush()
{
_a.Flush();
_b.Flush();
}
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
_a.Write(buffer, offset, count);
_b.Write(buffer, offset, count);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
2019-11-21 15:49:14 +00:00
if (!_leaveAOpen) _a.Dispose();
if (!_leaveBOpen) _b.Dispose();
}
}
}
2019-09-14 04:35:42 +00:00
}