Issue 771, remove throw on flush for readonly streams

This commit is contained in:
Lars Vahlenberg
2024-01-06 00:14:34 +01:00
parent 741712f89f
commit 4477833b1d
16 changed files with 25 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ internal sealed class RarCryptoWrapper : Stream
_rijndael = new BlockTransformer(key.Transformer(salt));
}
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();

View File

@@ -1393,7 +1393,7 @@ internal class ArchiveReader
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => throw new NotSupportedException();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using SharpCompress.IO;
@@ -47,7 +47,7 @@ internal class TarReadOnlySubStream : NonDisposingStream
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => throw new NotSupportedException();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
namespace SharpCompress.Common.Zip;
@@ -87,10 +87,7 @@ internal class PkwareTraditionalCryptoStream : Stream
_stream.Write(encrypted, 0, encrypted.Length);
}
public override void Flush()
{
//throw new NotSupportedException();
}
public override void Flush() { }
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();

View File

@@ -73,7 +73,7 @@ internal class WinzipAesCryptoStream : Stream
}
}
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override int Read(byte[] buffer, int offset, int count)
{

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
namespace SharpCompress.Compressors.Filters;
@@ -79,7 +79,7 @@ internal class BCJ2Filter : Stream
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => _baseStream.Length + _data1.Length + _data2.Length;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
namespace SharpCompress.Compressors.Filters;
@@ -40,7 +40,7 @@ internal abstract class Filter : Stream
public override bool CanWrite => _isEncoder;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => _baseStream.Length;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using SharpCompress.Common.SevenZip;
using SharpCompress.Compressors.LZMA.Utilites;
@@ -14,7 +14,7 @@ internal abstract class DecoderStream2 : Stream
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => throw new NotSupportedException();

View File

@@ -130,7 +130,7 @@ internal sealed class MultiVolumeReadOnlyStream : Stream
public byte[] CurrentCrc { get; private set; }
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => throw new NotSupportedException();

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using System;
using System.IO;
@@ -23,7 +23,7 @@ public abstract class ReadOnlyStream : Stream
set => throw new NotSupportedException();
}
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
namespace SharpCompress.IO;
@@ -26,7 +26,7 @@ internal class BufferedSubStream : NonDisposingStream
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => BytesLeftToRead;

View File

@@ -45,7 +45,7 @@ public class DataDescriptorStream : Stream
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => _stream.Length;

View File

@@ -29,7 +29,7 @@ internal class ReadOnlySubStream : NonDisposingStream
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => throw new NotSupportedException();

View File

@@ -75,7 +75,7 @@ public class RewindableStream : Stream
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => stream.Length;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
namespace SharpCompress.Test.Mocks;
@@ -27,7 +27,7 @@ public class FlushOnDisposeStream : Stream, IDisposable
set => inner.Position = value;
}
public override void Flush() => throw new NotImplementedException();
public override void Flush() { }
public override int Read(byte[] buffer, int offset, int count) =>
inner.Read(buffer, offset, count);

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
namespace SharpCompress.Test.Mocks;
@@ -29,7 +29,7 @@ public class ForwardOnlyStream : Stream
public override bool CanSeek => false;
public override bool CanWrite => false;
public override void Flush() => throw new NotSupportedException();
public override void Flush() { }
public override long Length => throw new NotSupportedException();