Skip to content

Commit

Permalink
Merge pull request #801 from Erior/feature/771
Browse files Browse the repository at this point in the history
Issue 771, remove throw on flush for readonly streams
  • Loading branch information
adamhathcock committed Jan 8, 2024
2 parents 741712f + 4477833 commit a0d5037
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/SharpCompress/Common/Rar/RarCryptoWrapper.cs
Expand Up @@ -17,7 +17,7 @@ public RarCryptoWrapper(Stream actualStream, byte[] salt, ICryptKey key)
_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();

Expand Down
2 changes: 1 addition & 1 deletion src/SharpCompress/Common/SevenZip/ArchiveReader.cs
Expand Up @@ -1393,7 +1393,7 @@ public FolderUnpackStream(ArchiveDatabase db, int p, int startIndex, List<bool>

public override bool CanWrite => false;

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override long Length => throw new NotSupportedException();

Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Common/Tar/TarReadOnlySubStream.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using SharpCompress.IO;

Expand Down Expand Up @@ -47,7 +47,7 @@ protected override void Dispose(bool disposing)

public override bool CanWrite => false;

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override long Length => throw new NotSupportedException();

Expand Down
7 changes: 2 additions & 5 deletions src/SharpCompress/Common/Zip/PkwareTraditionalCryptoStream.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;

namespace SharpCompress.Common.Zip;
Expand Down Expand Up @@ -87,10 +87,7 @@ public override void Write(byte[] buffer, int offset, int count)
_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();

Expand Down
2 changes: 1 addition & 1 deletion src/SharpCompress/Common/Zip/WinzipAesCryptoStream.cs
Expand Up @@ -73,7 +73,7 @@ protected override void Dispose(bool disposing)
}
}

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override int Read(byte[] buffer, int offset, int count)
{
Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Compressors/Filters/BCJ2Filter.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;

namespace SharpCompress.Compressors.Filters;
Expand Down Expand Up @@ -79,7 +79,7 @@ protected override void Dispose(bool disposing)

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;

Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Compressors/Filters/Filter.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;

namespace SharpCompress.Compressors.Filters;
Expand Down Expand Up @@ -40,7 +40,7 @@ protected override void Dispose(bool disposing)

public override bool CanWrite => _isEncoder;

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override long Length => _baseStream.Length;

Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Compressors/LZMA/DecoderStream.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using SharpCompress.Common.SevenZip;
using SharpCompress.Compressors.LZMA.Utilites;
Expand All @@ -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();

Expand Down
Expand Up @@ -130,7 +130,7 @@ public override int Read(byte[] buffer, int offset, int count)

public byte[] CurrentCrc { get; private set; }

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override long Length => throw new NotSupportedException();

Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Compressors/Xz/ReadOnlyStream.cs
@@ -1,4 +1,4 @@
#nullable disable
#nullable disable

using System;
using System.IO;
Expand All @@ -23,7 +23,7 @@ public override long Position
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();

Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/IO/BufferedSubStream.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;

namespace SharpCompress.IO;
Expand Down Expand Up @@ -26,7 +26,7 @@ public BufferedSubStream(Stream stream, long origin, long bytesToRead)

public override bool CanWrite => false;

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override long Length => BytesLeftToRead;

Expand Down
2 changes: 1 addition & 1 deletion src/SharpCompress/IO/DataDescriptorStream.cs
Expand Up @@ -45,7 +45,7 @@ protected override void Dispose(bool disposing)

public override bool CanWrite => false;

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override long Length => _stream.Length;

Expand Down
2 changes: 1 addition & 1 deletion src/SharpCompress/IO/ReadOnlySubStream.cs
Expand Up @@ -29,7 +29,7 @@ public ReadOnlySubStream(Stream stream, long? origin, long bytesToRead)

public override bool CanWrite => false;

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override long Length => throw new NotSupportedException();

Expand Down
2 changes: 1 addition & 1 deletion src/SharpCompress/IO/RewindableStream.cs
Expand Up @@ -75,7 +75,7 @@ public void StartRecording()

public override bool CanWrite => false;

public override void Flush() => throw new NotSupportedException();
public override void Flush() { }

public override long Length => stream.Length;

Expand Down
4 changes: 2 additions & 2 deletions tests/SharpCompress.Test/Mocks/FlushOnDisposeStream.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;

namespace SharpCompress.Test.Mocks;
Expand Down Expand Up @@ -27,7 +27,7 @@ public override long Position
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);
Expand Down
4 changes: 2 additions & 2 deletions tests/SharpCompress.Test/Mocks/ForwardOnlyStream.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;

namespace SharpCompress.Test.Mocks;
Expand Down Expand Up @@ -29,7 +29,7 @@ protected override void Dispose(bool disposing)
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();

Expand Down

0 comments on commit a0d5037

Please sign in to comment.