2020-08-24 23:27:03 +01:00
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
namespace RomRepoMgr.Core;
|
|
|
|
|
|
|
|
|
|
internal sealed class StreamWithLength : Stream
|
2020-08-24 23:27:03 +01:00
|
|
|
{
|
2024-11-09 01:37:59 +00:00
|
|
|
readonly Stream _baseStream;
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public StreamWithLength(Stream baseStream, long length)
|
|
|
|
|
{
|
|
|
|
|
_baseStream = baseStream;
|
|
|
|
|
Length = length;
|
|
|
|
|
}
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public override bool CanRead => _baseStream.CanRead;
|
|
|
|
|
public override bool CanSeek => _baseStream.CanSeek;
|
|
|
|
|
public override bool CanWrite => _baseStream.CanWrite;
|
|
|
|
|
public override long Length { get; }
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public override long Position
|
|
|
|
|
{
|
|
|
|
|
get => throw new NotSupportedException();
|
|
|
|
|
set => throw new NotSupportedException();
|
|
|
|
|
}
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public override void Flush() => _baseStream.Flush();
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public override int Read(byte[] buffer, int offset, int count) => _baseStream.Read(buffer, offset, count);
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public override void SetLength(long value) => throw new NotSupportedException();
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
public override void Close()
|
|
|
|
|
{
|
|
|
|
|
_baseStream.Close();
|
|
|
|
|
base.Close();
|
2020-08-24 23:27:03 +01:00
|
|
|
}
|
|
|
|
|
}
|