1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
8 namespace Mono.Profiler.Log {
10 public class LogStream : Stream {
12 public Stream BaseStream { get; }
14 public virtual bool EndOfStream => BaseStream.Position == BaseStream.Length;
16 public override bool CanRead => true;
18 public override bool CanSeek => false;
20 public override bool CanWrite => false;
22 public override long Length => throw new NotSupportedException ();
24 public override long Position {
25 get => throw new NotSupportedException ();
26 set => throw new NotSupportedException ();
29 public LogStream (Stream baseStream)
31 if (baseStream == null)
32 throw new ArgumentNullException (nameof (baseStream));
34 if (!baseStream.CanRead)
35 throw new ArgumentException ("Stream does not support reading.", nameof (baseStream));
37 BaseStream = baseStream;
40 protected override void Dispose (bool disposing)
43 BaseStream.Dispose ();
46 public override void Flush ()
48 throw new NotSupportedException ();
51 public override int Read (byte[] buffer, int offset, int count)
53 return BaseStream.Read (buffer, offset, count);
56 public override long Seek (long offset, SeekOrigin origin)
58 throw new NotSupportedException ();
61 public override void SetLength (long value)
63 throw new NotSupportedException ();
66 public override void Write (byte[] buffer, int offset, int count)
68 throw new NotSupportedException ();