2020-08-24 23:27:03 +01:00
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
namespace RomRepoMgr.Core;
|
|
|
|
|
|
2025-07-08 01:18:07 +01:00
|
|
|
internal sealed class StreamWithLength(Stream baseStream, long length) : Stream
|
2020-08-24 23:27:03 +01:00
|
|
|
{
|
2025-07-08 01:18:07 +01:00
|
|
|
public override bool CanRead => baseStream.CanRead;
|
|
|
|
|
public override bool CanSeek => baseStream.CanSeek;
|
|
|
|
|
public override bool CanWrite => baseStream.CanWrite;
|
|
|
|
|
public override long Length { get; } = length;
|
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
|
|
|
|
2025-07-08 01:18:07 +01:00
|
|
|
public override void Flush() => baseStream.Flush();
|
2020-08-24 23:27:03 +01:00
|
|
|
|
2025-07-08 01:18:07 +01: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()
|
|
|
|
|
{
|
2025-07-08 01:18:07 +01:00
|
|
|
baseStream.Close();
|
2024-11-09 01:37:59 +00:00
|
|
|
base.Close();
|
2020-08-24 23:27:03 +01:00
|
|
|
}
|
|
|
|
|
}
|