more clean up
This commit is contained in:
parent
17776d0659
commit
eca7bcb515
71 changed files with 284 additions and 345 deletions
|
|
@ -257,7 +257,7 @@ csharp_style_namespace_declarations = file_scoped
|
|||
##########################################
|
||||
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
dotnet_diagnostic.CA1000.severity = suggestion # do not declare static members on generic types
|
||||
dotnet_diagnostic.CA1000.severity = error # do not declare static members on generic types
|
||||
dotnet_diagnostic.CA1001.severity = error # disposable field owners should be disposable
|
||||
dotnet_diagnostic.CA1018.severity = error # mark custom attributes with AttributeUsage
|
||||
dotnet_diagnostic.CA1036.severity = silent
|
||||
|
|
@ -267,29 +267,29 @@ dotnet_diagnostic.CA1069.severity = error # enums should not have duplicate valu
|
|||
dotnet_diagnostic.CA1304.severity = error # specify CultureInfo for culture-sensitive operations
|
||||
dotnet_diagnostic.CA1305.severity = suggestion # specify IFormatProvider
|
||||
dotnet_diagnostic.CA1307.severity = suggestion # specify StringComparison for clarity
|
||||
dotnet_diagnostic.CA1309.severity = suggestion # use ordinal StringComparison
|
||||
dotnet_diagnostic.CA1309.severity = error # use ordinal StringComparison
|
||||
dotnet_diagnostic.CA1310.severity = error # specify StringComparison for correctness
|
||||
dotnet_diagnostic.CA1507.severity = suggestion # use nameof in place of string literals
|
||||
dotnet_diagnostic.CA1507.severity = error # use nameof in place of string literals
|
||||
dotnet_diagnostic.CA1513.severity = suggestion # use ObjectDisposedException throw helper
|
||||
dotnet_diagnostic.CA1707.severity = suggestion # identifiers should not contain underscores
|
||||
dotnet_diagnostic.CA1708.severity = suggestion # identifiers should differ by more than case
|
||||
dotnet_diagnostic.CA1711.severity = suggestion # identifiers should not have incorrect suffixes
|
||||
dotnet_diagnostic.CA1716.severity = suggestion # identifiers should not match language keywords
|
||||
dotnet_diagnostic.CA1720.severity = suggestion # identifiers should not contain type names
|
||||
dotnet_diagnostic.CA1725.severity = suggestion # parameter names should match base declaration
|
||||
dotnet_diagnostic.CA1725.severity = error # parameter names should match base declaration
|
||||
dotnet_diagnostic.CA1805.severity = suggestion # avoid unnecessary default value initialization
|
||||
dotnet_diagnostic.CA1816.severity = suggestion # call GC.SuppressFinalize correctly
|
||||
dotnet_diagnostic.CA1822.severity = suggestion # mark members static when possible
|
||||
dotnet_diagnostic.CA1825.severity = error # avoid zero-length array allocations
|
||||
dotnet_diagnostic.CA1826.severity = silent
|
||||
dotnet_diagnostic.CA1827.severity = error # use Any() instead of Count()/LongCount() checks
|
||||
dotnet_diagnostic.CA1829.severity = suggestion # use Length or Count property instead of LINQ Count()
|
||||
dotnet_diagnostic.CA1829.severity = error # use Length or Count property instead of LINQ Count()
|
||||
dotnet_diagnostic.CA1834.severity = error # prefer StringBuilder.Append(char) for single chars
|
||||
dotnet_diagnostic.CA1845.severity = suggestion # use span-based string.Concat overloads
|
||||
dotnet_diagnostic.CA1848.severity = suggestion # use LoggerMessage for high-performance logging
|
||||
dotnet_diagnostic.CA1845.severity = error # use span-based string.Concat overloads
|
||||
dotnet_diagnostic.CA1848.severity = error # use LoggerMessage for high-performance logging
|
||||
dotnet_diagnostic.CA1852.severity = suggestion # seal types that are not intended for inheritance
|
||||
dotnet_diagnostic.CA1860.severity = silent
|
||||
dotnet_diagnostic.CA2016.severity = suggestion # forward CancellationToken to invoked methods
|
||||
dotnet_diagnostic.CA2016.severity = error # forward CancellationToken to invoked methods
|
||||
dotnet_diagnostic.CA2201.severity = error # do not throw reserved or overly general exceptions
|
||||
dotnet_diagnostic.CA2206.severity = error # enforce CA2206 usage guidance
|
||||
dotnet_diagnostic.CA2208.severity = error # instantiate ArgumentException types correctly
|
||||
|
|
@ -297,12 +297,12 @@ dotnet_diagnostic.CA2211.severity = error # non-constant fields should not be vi
|
|||
dotnet_diagnostic.CA2249.severity = error # prefer string.Contains over string.IndexOf checks
|
||||
dotnet_diagnostic.CA2251.severity = error # use string.Equals over string.Compare equality checks
|
||||
dotnet_diagnostic.CA2252.severity = none
|
||||
dotnet_diagnostic.CA2254.severity = suggestion # logging message templates should be static expressions
|
||||
dotnet_diagnostic.CA2254.severity = error # logging message templates should be static expressions
|
||||
|
||||
; High volume analyzers requiring extensive refactoring - set to suggestion temporarily
|
||||
dotnet_diagnostic.CA1835.severity = suggestion # prefer Memory<T>-based async overloads
|
||||
dotnet_diagnostic.CA1510.severity = suggestion # use ArgumentNullException.ThrowIfNull
|
||||
dotnet_diagnostic.CA1512.severity = suggestion # use ArgumentOutOfRangeException throw helpers
|
||||
dotnet_diagnostic.CA1510.severity = error # use ArgumentNullException.ThrowIfNull
|
||||
dotnet_diagnostic.CA1512.severity = error # use ArgumentOutOfRangeException throw helpers
|
||||
dotnet_diagnostic.CA1844.severity = suggestion # provide memory-based async stream overrides
|
||||
dotnet_diagnostic.CA1825.severity = error # avoid zero-length array allocations
|
||||
dotnet_diagnostic.CA1712.severity = suggestion # do not prefix enum values with type name
|
||||
|
|
@ -310,11 +310,11 @@ dotnet_diagnostic.CA2022.severity = suggestion # avoid inexact reads with Stream
|
|||
dotnet_diagnostic.CA1850.severity = error # prefer static HashData over ComputeHash
|
||||
dotnet_diagnostic.CA2263.severity = error # prefer generic overload when type is known
|
||||
dotnet_diagnostic.CA2012.severity = suggestion # use ValueTasks correctly
|
||||
dotnet_diagnostic.CA1001.severity = suggestion # disposable field owners should be disposable
|
||||
dotnet_diagnostic.CA1001.severity = error # disposable field owners should be disposable
|
||||
|
||||
dotnet_diagnostic.CS0169.severity = error # field is never used
|
||||
dotnet_diagnostic.CS0219.severity = error # variable assigned but never used
|
||||
dotnet_diagnostic.CS0649.severity = suggestion # field is never assigned and remains default
|
||||
dotnet_diagnostic.CS0649.severity = error # field is never assigned and remains default
|
||||
dotnet_diagnostic.CS1998.severity = error # async method lacks await operators
|
||||
dotnet_diagnostic.CS8602.severity = error # possible null reference dereference
|
||||
dotnet_diagnostic.CS8604.severity = error # possible null reference argument
|
||||
|
|
|
|||
|
|
@ -650,7 +650,7 @@ static double ParseTimeValue(string timeStr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
var value = double.Parse(match.Groups[1].Value);
|
||||
var value = double.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture);
|
||||
var unit = match.Groups[2].Value.ToLower(CultureInfo.InvariantCulture);
|
||||
|
||||
// Convert to microseconds for comparison
|
||||
|
|
@ -679,7 +679,7 @@ static double ParseMemoryValue(string memStr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
var value = double.Parse(match.Groups[1].Value);
|
||||
var value = double.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture);
|
||||
var unit = match.Groups[2].Value.ToUpper(CultureInfo.InvariantCulture);
|
||||
|
||||
// Convert to KB for comparison
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public partial class GZipArchive
|
|||
}
|
||||
|
||||
protected override GZipArchiveEntry CreateEntryInternal(
|
||||
string filePath,
|
||||
string key,
|
||||
Stream source,
|
||||
long size,
|
||||
DateTime? modified,
|
||||
|
|
@ -48,13 +48,11 @@ public partial class GZipArchive
|
|||
{
|
||||
throw new InvalidFormatException("Only one entry is allowed in a GZip Archive");
|
||||
}
|
||||
return new GZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
|
||||
return new GZipWritableArchiveEntry(this, source, key, size, modified, closeStream);
|
||||
}
|
||||
|
||||
protected override GZipArchiveEntry CreateDirectoryEntry(
|
||||
string directoryPath,
|
||||
DateTime? modified
|
||||
) => throw new NotSupportedException("GZip archives do not support directory entries.");
|
||||
protected override GZipArchiveEntry CreateDirectoryEntry(string key, DateTime? modified) =>
|
||||
throw new NotSupportedException("GZip archives do not support directory entries.");
|
||||
|
||||
protected override void SaveTo(
|
||||
Stream stream,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public partial class RarArchive
|
|||
return new((IRarAsyncArchive)OpenArchive(new FileInfo(path), readerOptions));
|
||||
}
|
||||
|
||||
public static IRarArchive OpenArchive(string filePath, ReaderOptions? options = null)
|
||||
public static IRarArchive OpenArchive(string filePath, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
|
|
@ -39,24 +39,24 @@ public partial class RarArchive
|
|||
new SourceStream(
|
||||
fileInfo,
|
||||
i => RarArchiveVolumeFactory.GetFilePart(i, fileInfo),
|
||||
options ?? new ReaderOptions()
|
||||
readerOptions ?? new ReaderOptions()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IRarArchive OpenArchive(FileInfo fileInfo, ReaderOptions? options = null)
|
||||
public static IRarArchive OpenArchive(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
return new RarArchive(
|
||||
new SourceStream(
|
||||
fileInfo,
|
||||
i => RarArchiveVolumeFactory.GetFilePart(i, fileInfo),
|
||||
options ?? new ReaderOptions()
|
||||
readerOptions ?? new ReaderOptions()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IRarArchive OpenArchive(Stream stream, ReaderOptions? options = null)
|
||||
public static IRarArchive OpenArchive(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
|
||||
|
|
@ -65,7 +65,9 @@ public partial class RarArchive
|
|||
throw new ArgumentException("Stream must be seekable", nameof(stream));
|
||||
}
|
||||
|
||||
return new RarArchive(new SourceStream(stream, _ => null, options ?? new ReaderOptions()));
|
||||
return new RarArchive(
|
||||
new SourceStream(stream, _ => null, readerOptions ?? new ReaderOptions())
|
||||
);
|
||||
}
|
||||
|
||||
public static IRarArchive OpenArchive(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public partial class SevenZipArchive
|
|||
|
||||
public static IArchive OpenArchive(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull("fileInfo");
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
return new SevenZipArchive(
|
||||
new SourceStream(
|
||||
fileInfo,
|
||||
|
|
@ -81,7 +81,7 @@ public partial class SevenZipArchive
|
|||
|
||||
public static IArchive OpenArchive(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull("stream");
|
||||
stream.NotNull(nameof(stream));
|
||||
|
||||
if (stream is not { CanSeek: true })
|
||||
{
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ public partial class TarArchive
|
|||
}
|
||||
|
||||
protected override TarArchiveEntry CreateEntryInternal(
|
||||
string filePath,
|
||||
string key,
|
||||
Stream source,
|
||||
long size,
|
||||
DateTime? modified,
|
||||
|
|
@ -192,16 +192,14 @@ public partial class TarArchive
|
|||
this,
|
||||
source,
|
||||
CompressionType.Unknown,
|
||||
filePath,
|
||||
key,
|
||||
size,
|
||||
modified,
|
||||
closeStream
|
||||
);
|
||||
|
||||
protected override TarArchiveEntry CreateDirectoryEntry(
|
||||
string directoryPath,
|
||||
DateTime? modified
|
||||
) => new TarWritableArchiveEntry(this, directoryPath, modified);
|
||||
protected override TarArchiveEntry CreateDirectoryEntry(string key, DateTime? modified) =>
|
||||
new TarWritableArchiveEntry(this, key, modified);
|
||||
|
||||
protected override void SaveTo(
|
||||
Stream stream,
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ public partial class ZipArchive
|
|||
internal ZipArchive()
|
||||
: base(ArchiveType.Zip) { }
|
||||
|
||||
protected override IEnumerable<ZipVolume> LoadVolumes(SourceStream stream)
|
||||
protected override IEnumerable<ZipVolume> LoadVolumes(SourceStream sourceStream)
|
||||
{
|
||||
stream.LoadAllParts();
|
||||
sourceStream.LoadAllParts();
|
||||
//stream.Position = 0;
|
||||
|
||||
var streams = stream.Streams.ToList();
|
||||
var streams = sourceStream.Streams.ToList();
|
||||
var idx = 0;
|
||||
if (streams.Count() > 1)
|
||||
if (streams.Count > 1)
|
||||
{
|
||||
//check if second stream is zip header without changing position
|
||||
var headerProbeStream = streams[1];
|
||||
|
|
@ -51,7 +51,7 @@ public partial class ZipArchive
|
|||
headerProbeStream.Position = startPosition;
|
||||
if (isZip)
|
||||
{
|
||||
stream.IsVolumes = true;
|
||||
sourceStream.IsVolumes = true;
|
||||
|
||||
var tmp = streams[0];
|
||||
streams.RemoveAt(0);
|
||||
|
|
@ -61,7 +61,7 @@ public partial class ZipArchive
|
|||
}
|
||||
}
|
||||
|
||||
return new ZipVolume(stream, ReaderOptions, idx++).AsEnumerable();
|
||||
return new ZipVolume(sourceStream, ReaderOptions, idx++).AsEnumerable();
|
||||
}
|
||||
|
||||
protected override IEnumerable<ZipArchiveEntry> LoadEntries(IEnumerable<ZipVolume> volumes)
|
||||
|
|
@ -150,17 +150,15 @@ public partial class ZipArchive
|
|||
}
|
||||
|
||||
protected override ZipArchiveEntry CreateEntryInternal(
|
||||
string filePath,
|
||||
string key,
|
||||
Stream source,
|
||||
long size,
|
||||
DateTime? modified,
|
||||
bool closeStream
|
||||
) => new ZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
|
||||
) => new ZipWritableArchiveEntry(this, source, key, size, modified, closeStream);
|
||||
|
||||
protected override ZipArchiveEntry CreateDirectoryEntry(
|
||||
string directoryPath,
|
||||
DateTime? modified
|
||||
) => new ZipWritableArchiveEntry(this, directoryPath, modified);
|
||||
protected override ZipArchiveEntry CreateDirectoryEntry(string key, DateTime? modified) =>
|
||||
new ZipWritableArchiveEntry(this, key, modified);
|
||||
|
||||
protected override IReader CreateReaderForSolidExtraction()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ public sealed partial class AceFileHeader
|
|||
/// Supports both ACE 1.0 and ACE 2.0 formats.
|
||||
/// </summary>
|
||||
public override async ValueTask<AceHeader?> ReadAsync(
|
||||
Stream stream,
|
||||
Stream reader,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
var headerData = await ReadHeaderAsync(stream, cancellationToken).ConfigureAwait(false);
|
||||
var headerData = await ReadHeaderAsync(reader, cancellationToken).ConfigureAwait(false);
|
||||
if (headerData.Length == 0)
|
||||
{
|
||||
return null;
|
||||
|
|
@ -104,7 +104,7 @@ public sealed partial class AceFileHeader
|
|||
}
|
||||
|
||||
// Store the data start position
|
||||
DataStartPosition = stream.Position;
|
||||
DataStartPosition = reader.Position;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ public sealed partial class AceFileHeader : AceHeader
|
|||
/// Returns null if no more entries or end of archive.
|
||||
/// Supports both ACE 1.0 and ACE 2.0 formats.
|
||||
/// </summary>
|
||||
public override AceHeader? Read(Stream stream)
|
||||
public override AceHeader? Read(Stream reader)
|
||||
{
|
||||
var headerData = ReadHeader(stream);
|
||||
var headerData = ReadHeader(reader);
|
||||
if (headerData.Length == 0)
|
||||
{
|
||||
return null;
|
||||
|
|
@ -144,7 +144,7 @@ public sealed partial class AceFileHeader : AceHeader
|
|||
}
|
||||
|
||||
// Store the data start position
|
||||
DataStartPosition = stream.Position;
|
||||
DataStartPosition = reader.Position;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ public sealed partial class AceMainHeader
|
|||
/// Supports both ACE 1.0 and ACE 2.0 formats.
|
||||
/// </summary>
|
||||
public override async ValueTask<AceHeader?> ReadAsync(
|
||||
Stream stream,
|
||||
Stream reader,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
var headerData = await ReadHeaderAsync(stream, cancellationToken).ConfigureAwait(false);
|
||||
var headerData = await ReadHeaderAsync(reader, cancellationToken).ConfigureAwait(false);
|
||||
if (headerData.Length == 0)
|
||||
{
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ public sealed partial class AceMainHeader : AceHeader
|
|||
/// Returns header if this is a valid ACE archive.
|
||||
/// Supports both ACE 1.0 and ACE 2.0 formats.
|
||||
/// </summary>
|
||||
public override AceHeader? Read(Stream stream)
|
||||
public override AceHeader? Read(Stream reader)
|
||||
{
|
||||
var headerData = ReadHeader(stream);
|
||||
var headerData = ReadHeader(reader);
|
||||
if (headerData.Length == 0)
|
||||
{
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ namespace SharpCompress.Common.Arj.Headers;
|
|||
public partial class ArjLocalHeader
|
||||
{
|
||||
public override async ValueTask<ArjHeader?> ReadAsync(
|
||||
Stream stream,
|
||||
Stream reader,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
var body = await ReadHeaderAsync(stream, cancellationToken).ConfigureAwait(false);
|
||||
var body = await ReadHeaderAsync(reader, cancellationToken).ConfigureAwait(false);
|
||||
if (body.Length > 0)
|
||||
{
|
||||
await ReadExtendedHeadersAsync(stream, cancellationToken).ConfigureAwait(false);
|
||||
await ReadExtendedHeadersAsync(reader, cancellationToken).ConfigureAwait(false);
|
||||
var header = LoadFrom(body);
|
||||
header.DataStartPosition = stream.Position;
|
||||
header.DataStartPosition = reader.Position;
|
||||
return header;
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ public partial class ArjLocalHeader : ArjHeader
|
|||
archiveEncoding ?? throw new ArgumentNullException(nameof(archiveEncoding));
|
||||
}
|
||||
|
||||
public override ArjHeader? Read(Stream stream)
|
||||
public override ArjHeader? Read(Stream reader)
|
||||
{
|
||||
var body = ReadHeader(stream);
|
||||
var body = ReadHeader(reader);
|
||||
if (body.Length > 0)
|
||||
{
|
||||
ReadExtendedHeaders(stream);
|
||||
ReadExtendedHeaders(reader);
|
||||
var header = LoadFrom(body);
|
||||
header.DataStartPosition = stream.Position;
|
||||
header.DataStartPosition = reader.Position;
|
||||
return header;
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ namespace SharpCompress.Common.Arj.Headers;
|
|||
public partial class ArjMainHeader
|
||||
{
|
||||
public override async ValueTask<ArjHeader?> ReadAsync(
|
||||
Stream stream,
|
||||
Stream reader,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
var body = await ReadHeaderAsync(stream, cancellationToken).ConfigureAwait(false);
|
||||
await ReadExtendedHeadersAsync(stream, cancellationToken).ConfigureAwait(false);
|
||||
var body = await ReadHeaderAsync(reader, cancellationToken).ConfigureAwait(false);
|
||||
await ReadExtendedHeadersAsync(reader, cancellationToken).ConfigureAwait(false);
|
||||
return LoadFrom(body);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ public partial class ArjMainHeader : ArjHeader
|
|||
archiveEncoding ?? throw new ArgumentNullException(nameof(archiveEncoding));
|
||||
}
|
||||
|
||||
public override ArjHeader? Read(Stream stream)
|
||||
public override ArjHeader? Read(Stream reader)
|
||||
{
|
||||
var body = ReadHeader(stream);
|
||||
ReadExtendedHeaders(stream);
|
||||
var body = ReadHeader(reader);
|
||||
ReadExtendedHeaders(reader);
|
||||
return LoadFrom(body);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ using SharpCompress.IO;
|
|||
|
||||
namespace SharpCompress.Common.Rar;
|
||||
|
||||
internal class AsyncMarkingBinaryReader
|
||||
internal class AsyncMarkingBinaryReader : IDisposable
|
||||
#if NET8_0_OR_GREATER
|
||||
, IAsyncDisposable
|
||||
#endif
|
||||
{
|
||||
private readonly AsyncBinaryReader _reader;
|
||||
|
||||
|
|
@ -187,4 +190,9 @@ internal class AsyncMarkingBinaryReader
|
|||
|
||||
throw new FormatException("malformed vint");
|
||||
}
|
||||
|
||||
public virtual void Dispose() => _reader.Dispose();
|
||||
#if NET8_0_OR_GREATER
|
||||
public virtual ValueTask DisposeAsync() => _reader.DisposeAsync();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,7 +249,9 @@ public abstract class RarVolume : Volume
|
|||
}
|
||||
|
||||
// we only want to load the archive header to avoid overhead but have to do the nasty thing and reset the stream
|
||||
#pragma warning disable CA2016 // Forward token if available; polyfill FirstAsync has no token overload
|
||||
await GetVolumeFilePartsAsync(cancellationToken).FirstAsync().ConfigureAwait(false);
|
||||
#pragma warning restore CA2016
|
||||
Stream.Position = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ internal sealed partial class TarHeader
|
|||
LastModifiedTime = EPOCH.AddSeconds(unixTimeStamp).ToLocalTime();
|
||||
Magic = ArchiveEncoding.Decode(buffer, 257, 6).TrimNulls();
|
||||
|
||||
if (!string.IsNullOrEmpty(Magic) && "ustar".Equals(Magic))
|
||||
if (!string.IsNullOrEmpty(Magic) && "ustar".Equals(Magic, StringComparison.Ordinal))
|
||||
{
|
||||
var namePrefix = ArchiveEncoding.Decode(buffer, 345, 157).TrimNulls();
|
||||
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ internal sealed partial class TarHeader
|
|||
LastModifiedTime = EPOCH.AddSeconds(unixTimeStamp).ToLocalTime();
|
||||
Magic = ArchiveEncoding.Decode(buffer, 257, 6).TrimNulls();
|
||||
|
||||
if (!string.IsNullOrEmpty(Magic) && "ustar".Equals(Magic))
|
||||
if (!string.IsNullOrEmpty(Magic) && "ustar".Equals(Magic, StringComparison.Ordinal))
|
||||
{
|
||||
var namePrefix = ArchiveEncoding.Decode(buffer, 345, 157).TrimNulls();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,7 @@ internal abstract partial class ZipFileEntry
|
|||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
if (archiveStream is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(archiveStream));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(archiveStream);
|
||||
|
||||
var buffer = new byte[12];
|
||||
await archiveStream.ReadFullyAsync(buffer, 0, 12, cancellationToken).ConfigureAwait(false);
|
||||
|
|
|
|||
|
|
@ -44,10 +44,7 @@ internal abstract partial class ZipFileEntry(ZipHeaderType type, IArchiveEncodin
|
|||
|
||||
internal PkwareTraditionalEncryptionData ComposeEncryptionData(Stream archiveStream)
|
||||
{
|
||||
if (archiveStream is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(archiveStream));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(archiveStream);
|
||||
|
||||
var buffer = new byte[12];
|
||||
archiveStream.ReadFully(buffer);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,7 @@ internal partial class PkwareTraditionalCryptoStream
|
|||
throw new NotSupportedException("This stream does not encrypt via Read()");
|
||||
}
|
||||
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
|
||||
var temp = new byte[count];
|
||||
var readBytes = await _stream
|
||||
|
|
|
|||
|
|
@ -48,10 +48,7 @@ internal partial class PkwareTraditionalCryptoStream : Stream
|
|||
throw new NotSupportedException("This stream does not encrypt via Read()");
|
||||
}
|
||||
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
|
||||
var temp = new byte[count];
|
||||
var readBytes = _stream.Read(temp, 0, count);
|
||||
|
|
|
|||
|
|
@ -69,10 +69,7 @@ internal class PkwareTraditionalEncryptionData
|
|||
|
||||
public byte[] Encrypt(byte[] plainText, int length)
|
||||
{
|
||||
if (plainText is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(plainText));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(plainText);
|
||||
|
||||
if (length > plainText.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,18 +47,9 @@ public sealed partial class ADCStream
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
if (offset < buffer.GetLowerBound(0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
ThrowHelper.ThrowIfNegative(count);
|
||||
ThrowHelper.ThrowIfLessThan(offset, buffer.GetLowerBound(0));
|
||||
if ((offset + count) > buffer.GetLength(0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
|
|
|||
|
|
@ -110,18 +110,9 @@ public sealed partial class ADCStream : Stream
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
if (offset < buffer.GetLowerBound(0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
ThrowHelper.ThrowIfNegative(count);
|
||||
ThrowHelper.ThrowIfLessThan(offset, buffer.GetLowerBound(0));
|
||||
if ((offset + count) > buffer.GetLength(0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public partial class ArcLzwStream
|
|||
totalRead += read;
|
||||
}
|
||||
var decoded = Decompress(data, _useCrunched);
|
||||
var result = decoded.Count();
|
||||
var result = decoded.Count;
|
||||
if (_useCrunched)
|
||||
{
|
||||
var unpacked = RLE.UnpackRLE(decoded.ToArray());
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public partial class ArcLzwStream : Stream
|
|||
var data = new byte[_compressedSize];
|
||||
_stream.Read(data, 0, _compressedSize);
|
||||
var decoded = Decompress(data, _useCrunched);
|
||||
var result = decoded.Count();
|
||||
var result = decoded.Count;
|
||||
if (_useCrunched)
|
||||
{
|
||||
var unpacked = RLE.UnpackRLE(decoded.ToArray());
|
||||
|
|
|
|||
|
|
@ -61,10 +61,7 @@ public sealed partial class HuffTree
|
|||
|
||||
public void BuildTree(byte[] lengths, int count)
|
||||
{
|
||||
if (lengths == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(lengths));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(lengths);
|
||||
|
||||
if (count < 0 || count > lengths.Length)
|
||||
{
|
||||
|
|
@ -85,10 +82,7 @@ public sealed partial class HuffTree
|
|||
|
||||
public void BuildTree(byte[] valueLengths)
|
||||
{
|
||||
if (valueLengths == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(valueLengths));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(valueLengths);
|
||||
|
||||
if (valueLengths.Length > TreeEntry.MAX_INDEX / 2)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,10 +92,7 @@ public sealed partial class LHDecoderStream
|
|||
throw new ObjectDisposedException(nameof(LHDecoderStream));
|
||||
}
|
||||
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
|
||||
if (offset < 0 || count < 0 || offset + count > buffer.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -123,10 +123,7 @@ public sealed partial class LHDecoderStream : Stream
|
|||
throw new ObjectDisposedException(nameof(LHDecoderStream));
|
||||
}
|
||||
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
|
||||
if (offset < 0 || count < 0 || offset + count > buffer.Length)
|
||||
{
|
||||
|
|
@ -179,4 +176,14 @@ public sealed partial class LHDecoderStream : Stream
|
|||
|
||||
public override void Write(byte[] buffer, int offset, int count) =>
|
||||
throw new NotSupportedException();
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && !_disposed)
|
||||
{
|
||||
_disposed = true;
|
||||
_stream.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ public sealed partial class LhaStream<TDecoderConfig>
|
|||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
if (offset < 0 || count < 0 || (offset + count) > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
|
|
|
|||
|
|
@ -57,10 +57,7 @@ public sealed partial class LhaStream<TDecoderConfig> : Stream
|
|||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
if (offset < 0 || count < 0 || (offset + count) > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
|
|
|
|||
|
|
@ -883,18 +883,9 @@ internal class ZlibBaseStream : Stream, IStreamStack
|
|||
|
||||
return rc;
|
||||
}
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
if (offset < buffer.GetLowerBound(0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
ThrowHelper.ThrowIfNegative(count);
|
||||
ThrowHelper.ThrowIfLessThan(offset, buffer.GetLowerBound(0));
|
||||
if ((offset + count) > buffer.GetLength(0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
|
@ -1073,18 +1064,9 @@ internal class ZlibBaseStream : Stream, IStreamStack
|
|||
|
||||
return rc;
|
||||
}
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
if (offset < buffer.GetLowerBound(0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
ThrowHelper.ThrowIfNegative(count);
|
||||
ThrowHelper.ThrowIfLessThan(offset, buffer.GetLowerBound(0));
|
||||
if ((offset + count) > buffer.GetLength(0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ namespace SharpCompress.Compressors.Deflate64;
|
|||
public sealed partial class Deflate64Stream
|
||||
{
|
||||
public override async Task<int> ReadAsync(
|
||||
byte[] array,
|
||||
byte[] buffer,
|
||||
int offset,
|
||||
int count,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
ValidateParameters(array, offset, count);
|
||||
ValidateParameters(buffer, offset, count);
|
||||
EnsureNotDisposed();
|
||||
|
||||
int bytesRead;
|
||||
|
|
@ -26,7 +26,7 @@ public sealed partial class Deflate64Stream
|
|||
|
||||
while (true)
|
||||
{
|
||||
bytesRead = _inflater.Inflate(array, currentOffset, remainingCount);
|
||||
bytesRead = _inflater.Inflate(buffer, currentOffset, remainingCount);
|
||||
currentOffset += bytesRead;
|
||||
remainingCount -= bytesRead;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,7 @@ public sealed partial class Deflate64Stream : Stream
|
|||
|
||||
public Deflate64Stream(Stream stream, CompressionMode mode)
|
||||
{
|
||||
if (stream is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(stream);
|
||||
|
||||
if (mode != CompressionMode.Decompress)
|
||||
{
|
||||
|
|
@ -72,9 +69,9 @@ public sealed partial class Deflate64Stream : Stream
|
|||
public override void SetLength(long value) =>
|
||||
throw new NotSupportedException("Deflate64: not supported");
|
||||
|
||||
public override int Read(byte[] array, int offset, int count)
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
ValidateParameters(array, offset, count);
|
||||
ValidateParameters(buffer, offset, count);
|
||||
EnsureNotDisposed();
|
||||
|
||||
int bytesRead;
|
||||
|
|
@ -83,7 +80,7 @@ public sealed partial class Deflate64Stream : Stream
|
|||
|
||||
while (true)
|
||||
{
|
||||
bytesRead = _inflater.Inflate(array, currentOffset, remainingCount);
|
||||
bytesRead = _inflater.Inflate(buffer, currentOffset, remainingCount);
|
||||
currentOffset += bytesRead;
|
||||
remainingCount -= bytesRead;
|
||||
|
||||
|
|
@ -118,20 +115,11 @@ public sealed partial class Deflate64Stream : Stream
|
|||
|
||||
private void ValidateParameters(byte[] array, int offset, int count)
|
||||
{
|
||||
if (array is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(array);
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
ThrowHelper.ThrowIfNegative(offset);
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
ThrowHelper.ThrowIfNegative(count);
|
||||
|
||||
if (array.Length - offset < count)
|
||||
{
|
||||
|
|
@ -155,7 +143,7 @@ public sealed partial class Deflate64Stream : Stream
|
|||
private static void ThrowCannotWriteToDeflateManagedStreamException() =>
|
||||
throw new InvalidOperationException("Deflate64: cannot write to this stream");
|
||||
|
||||
public override void Write(byte[] array, int offset, int count) =>
|
||||
public override void Write(byte[] buffer, int offset, int count) =>
|
||||
ThrowCannotWriteToDeflateManagedStreamException();
|
||||
|
||||
// This is called by Dispose:
|
||||
|
|
|
|||
|
|
@ -91,10 +91,7 @@ internal sealed class BinTree : InWindow
|
|||
uint keepAddBufferAfter
|
||||
)
|
||||
{
|
||||
if (historySize > K_MAX_VAL_FOR_NORMALIZE - 256)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(historySize));
|
||||
}
|
||||
ThrowHelper.ThrowIfGreaterThan(historySize, K_MAX_VAL_FOR_NORMALIZE - 256);
|
||||
_cutValue = 16 + (matchMaxLen >> 1);
|
||||
|
||||
var windowReservSize =
|
||||
|
|
|
|||
|
|
@ -151,15 +151,9 @@ internal partial class Model
|
|||
/// </summary>
|
||||
public void Encode(Stream target, Stream source, PpmdProperties properties)
|
||||
{
|
||||
if (target is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(target));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(target);
|
||||
|
||||
if (source is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(source);
|
||||
|
||||
EncodeStart(properties);
|
||||
EncodeBlock(target, source, true);
|
||||
|
|
@ -239,15 +233,9 @@ internal partial class Model
|
|||
/// </summary>
|
||||
public void Decode(Stream target, Stream source, PpmdProperties properties)
|
||||
{
|
||||
if (target is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(target));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(target);
|
||||
|
||||
if (source is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(source);
|
||||
|
||||
DecodeStart(source, properties);
|
||||
var buffer = new byte[65536];
|
||||
|
|
|
|||
|
|
@ -90,10 +90,7 @@ public class PpmdStream : Stream
|
|||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
if (stream is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(stream);
|
||||
|
||||
if (properties.Version == PpmdVersion.H && compress)
|
||||
{
|
||||
|
|
@ -171,21 +168,21 @@ public class PpmdStream : Stream
|
|||
|
||||
public override void Flush() { }
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_isDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_isDisposed = true;
|
||||
if (isDisposing)
|
||||
if (disposing)
|
||||
{
|
||||
if (_compress)
|
||||
{
|
||||
_model.EncodeBlock(_stream, new MemoryStream(), true);
|
||||
}
|
||||
}
|
||||
base.Dispose(isDisposing);
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override long Length => throw new NotSupportedException();
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@ public partial class RunLength90Stream
|
|||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
|
||||
if (offset < 0 || count < 0 || offset + count > buffer.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,10 +53,7 @@ public partial class RunLength90Stream : Stream
|
|||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
|
||||
if (offset < 0 || count < 0 || offset + count > buffer.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ internal sealed partial class Unpack : BitInput, IRarUnpack
|
|||
if (!disposed)
|
||||
{
|
||||
base.Dispose();
|
||||
if (!externalWindow && window is not null)
|
||||
if (window is not null)
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(window);
|
||||
window = null;
|
||||
|
|
@ -91,8 +91,6 @@ internal sealed partial class Unpack : BitInput, IRarUnpack
|
|||
|
||||
private BlockTypes unpBlockType;
|
||||
|
||||
private bool externalWindow;
|
||||
|
||||
private long writtenFileSize;
|
||||
|
||||
private bool ppmError;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@ internal static partial class MultiByteIntegers
|
|||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
if (maxBytes <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(maxBytes));
|
||||
}
|
||||
ThrowHelper.ThrowIfNegativeOrZero(maxBytes);
|
||||
|
||||
if (maxBytes > 9)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ internal static partial class MultiByteIntegers
|
|||
{
|
||||
public static ulong ReadXZInteger(this BinaryReader reader, int MaxBytes = 9)
|
||||
{
|
||||
if (MaxBytes <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(MaxBytes));
|
||||
}
|
||||
ThrowHelper.ThrowIfNegativeOrZero(MaxBytes);
|
||||
|
||||
if (MaxBytes > 9)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,20 +32,14 @@ public partial class CompressionStream : Stream
|
|||
bool leaveOpen = true
|
||||
)
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
SharpCompress.ThrowHelper.ThrowIfNull(stream);
|
||||
|
||||
if (!stream.CanWrite)
|
||||
{
|
||||
throw new ArgumentException("Stream is not writable", nameof(stream));
|
||||
}
|
||||
|
||||
if (bufferSize < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(bufferSize));
|
||||
}
|
||||
SharpCompress.ThrowHelper.ThrowIfNegative(bufferSize);
|
||||
|
||||
innerStream = stream;
|
||||
this.compressor = compressor;
|
||||
|
|
|
|||
|
|
@ -37,20 +37,14 @@ public partial class DecompressionStream : Stream
|
|||
bool leaveOpen = true
|
||||
)
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
SharpCompress.ThrowHelper.ThrowIfNull(stream);
|
||||
|
||||
if (!stream.CanRead)
|
||||
{
|
||||
throw new ArgumentException("Stream is not readable", nameof(stream));
|
||||
}
|
||||
|
||||
if (bufferSize < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(bufferSize));
|
||||
}
|
||||
SharpCompress.ThrowHelper.ThrowIfNegative(bufferSize);
|
||||
|
||||
innerStream = stream;
|
||||
this.decompressor = decompressor;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class LzwFactory : Factory, IReaderFactory
|
|||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return LzwReader.OpenAsyncReader(stream, options);
|
||||
return LzwReader.OpenAsyncReader(stream, options, cancellationToken);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ namespace SharpCompress.IO;
|
|||
internal class CountingStream : Stream
|
||||
{
|
||||
private readonly Stream _stream;
|
||||
private readonly bool _leaveOpen;
|
||||
private long _bytesWritten;
|
||||
|
||||
public CountingStream(Stream stream)
|
||||
|
|
@ -59,7 +58,7 @@ internal class CountingStream : Stream
|
|||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && !_leaveOpen)
|
||||
if (disposing)
|
||||
{
|
||||
_stream.Dispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,7 @@ internal sealed partial class SeekableSharpCompressStream : SharpCompressStream
|
|||
public SeekableSharpCompressStream(Stream stream, bool leaveStreamOpen = false)
|
||||
: base(Null, true, false, null)
|
||||
{
|
||||
if (stream is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(stream);
|
||||
if (!stream.CanSeek)
|
||||
{
|
||||
throw new ArgumentException("Stream must be seekable", nameof(stream));
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ internal static class NotNullExtensions
|
|||
)
|
||||
where T : class
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(obj, paramName);
|
||||
ThrowHelper.ThrowIfNull(obj, paramName);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -275,10 +275,7 @@ public sealed class CompressionProviderRegistry
|
|||
/// <exception cref="ArgumentNullException">If provider is null.</exception>
|
||||
public CompressionProviderRegistry With(ICompressionProvider provider)
|
||||
{
|
||||
if (provider is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(provider));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(provider);
|
||||
|
||||
var newProviders = new Dictionary<CompressionType, ICompressionProvider>(_providers)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,10 +126,7 @@ public abstract partial class AbstractReader<TEntry, TVolume>
|
|||
);
|
||||
}
|
||||
|
||||
if (writableStream is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(writableStream));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(writableStream);
|
||||
if (!writableStream.CanWrite)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
|
|
|
|||
|
|
@ -190,10 +190,7 @@ public abstract partial class AbstractReader<TEntry, TVolume> : IReader, IAsyncR
|
|||
throw new ArgumentException("WriteEntryTo or OpenEntryStream can only be called once.");
|
||||
}
|
||||
|
||||
if (writableStream is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(writableStream));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(writableStream);
|
||||
if (!writableStream.CanWrite)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ public partial class AceReader
|
|||
/// Opens an AceReader for non-seeking usage with a single volume.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream containing the ACE archive.</param>
|
||||
/// <param name="options">Reader options.</param>
|
||||
/// <param name="readerOptions">Reader options.</param>
|
||||
/// <returns>An AceReader instance.</returns>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new SingleVolumeAceReader(stream, options ?? new ReaderOptions());
|
||||
return new SingleVolumeAceReader(stream, readerOptions ?? new ReaderOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ public partial class ArcReader : AbstractReader<ArcEntry, ArcVolume>
|
|||
/// Opens an ArcReader for Non-seeking usage with a single volume
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="readerOptions"></param>
|
||||
/// <returns></returns>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new ArcReader(stream, options ?? new ReaderOptions());
|
||||
return new ArcReader(stream, readerOptions ?? new ReaderOptions());
|
||||
}
|
||||
|
||||
protected override IEnumerable<ArcEntry> GetEntries(Stream stream)
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ public abstract partial class ArjReader : AbstractReader<ArjEntry, ArjVolume>
|
|||
/// Opens an ArjReader for Non-seeking usage with a single volume
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="readerOptions"></param>
|
||||
/// <returns></returns>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new SingleVolumeArjReader(stream, options ?? new ReaderOptions());
|
||||
return new SingleVolumeArjReader(stream, readerOptions ?? new ReaderOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ public partial class GZipReader
|
|||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new GZipReader(stream, options ?? new ReaderOptions());
|
||||
return new GZipReader(stream, readerOptions ?? new ReaderOptions());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ public partial class LzwReader
|
|||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new LzwReader(stream, options ?? new ReaderOptions());
|
||||
return new LzwReader(stream, readerOptions ?? new ReaderOptions());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,16 +40,16 @@ public abstract partial class RarReader : AbstractReader<RarReaderEntry, RarVolu
|
|||
|
||||
public override RarVolume? Volume => volume;
|
||||
|
||||
public static IReader OpenReader(string filePath, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(string filePath, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenReader(new FileInfo(filePath), options);
|
||||
return OpenReader(new FileInfo(filePath), readerOptions);
|
||||
}
|
||||
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
options ??= new ReaderOptions { LeaveStreamOpen = false };
|
||||
return OpenReader(fileInfo.OpenRead(), options);
|
||||
readerOptions ??= new ReaderOptions { LeaveStreamOpen = false };
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
|
||||
public static IReader OpenReader(IEnumerable<string> filePaths, ReaderOptions? options = null)
|
||||
|
|
@ -67,12 +67,12 @@ public abstract partial class RarReader : AbstractReader<RarReaderEntry, RarVolu
|
|||
/// Opens a RarReader for Non-seeking usage with a single volume
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="readerOptions"></param>
|
||||
/// <returns></returns>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new SingleVolumeRarReader(stream, options ?? new ReaderOptions());
|
||||
return new SingleVolumeRarReader(stream, readerOptions ?? new ReaderOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -82,16 +82,16 @@ public partial class TarReader
|
|||
|
||||
public static async ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options = null,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
stream.NotNull(nameof(stream));
|
||||
options ??= new ReaderOptions();
|
||||
readerOptions ??= new ReaderOptions();
|
||||
var sharpCompressStream = SharpCompressStream.Create(
|
||||
stream,
|
||||
bufferSize: options.RewindableBufferSize
|
||||
bufferSize: readerOptions.RewindableBufferSize
|
||||
);
|
||||
long pos = sharpCompressStream.Position;
|
||||
foreach (var wrapper in TarWrapper.Wrappers)
|
||||
|
|
@ -110,8 +110,8 @@ public partial class TarReader
|
|||
var testStream = await CreateProbeDecompressionStreamAsync(
|
||||
sharpCompressStream,
|
||||
wrapper.CompressionType,
|
||||
options.Providers,
|
||||
options,
|
||||
readerOptions.Providers,
|
||||
readerOptions,
|
||||
cancellationToken
|
||||
)
|
||||
.ConfigureAwait(false);
|
||||
|
|
@ -120,7 +120,7 @@ public partial class TarReader
|
|||
)
|
||||
{
|
||||
sharpCompressStream.Position = pos;
|
||||
return new TarReader(sharpCompressStream, options, wrapper.CompressionType);
|
||||
return new TarReader(sharpCompressStream, readerOptions, wrapper.CompressionType);
|
||||
}
|
||||
|
||||
if (wrapper.CompressionType != CompressionType.None)
|
||||
|
|
@ -130,7 +130,7 @@ public partial class TarReader
|
|||
}
|
||||
|
||||
sharpCompressStream.Position = pos;
|
||||
return new TarReader(sharpCompressStream, options, CompressionType.None);
|
||||
return new TarReader(sharpCompressStream, readerOptions, CompressionType.None);
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
|
|
@ -160,15 +160,15 @@ public partial class TarReader
|
|||
/// Opens a TarReader for Non-seeking usage with a single volume
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="readerOptions"></param>
|
||||
/// <returns></returns>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
options ??= new ReaderOptions();
|
||||
readerOptions ??= new ReaderOptions();
|
||||
var sharpCompressStream = SharpCompressStream.Create(
|
||||
stream,
|
||||
bufferSize: options.RewindableBufferSize
|
||||
bufferSize: readerOptions.RewindableBufferSize
|
||||
);
|
||||
long pos = sharpCompressStream.Position;
|
||||
foreach (var wrapper in TarWrapper.Wrappers)
|
||||
|
|
@ -183,13 +183,13 @@ public partial class TarReader
|
|||
var testStream = CreateProbeDecompressionStream(
|
||||
sharpCompressStream,
|
||||
wrapper.CompressionType,
|
||||
options.Providers,
|
||||
options
|
||||
readerOptions.Providers,
|
||||
readerOptions
|
||||
);
|
||||
if (TarArchive.IsTarFile(testStream))
|
||||
{
|
||||
sharpCompressStream.Position = pos;
|
||||
return new TarReader(sharpCompressStream, options, wrapper.CompressionType);
|
||||
return new TarReader(sharpCompressStream, readerOptions, wrapper.CompressionType);
|
||||
}
|
||||
|
||||
if (wrapper.CompressionType != CompressionType.None)
|
||||
|
|
@ -199,6 +199,6 @@ public partial class TarReader
|
|||
}
|
||||
|
||||
sharpCompressStream.Position = pos;
|
||||
return new TarReader(sharpCompressStream, options, CompressionType.None);
|
||||
return new TarReader(sharpCompressStream, readerOptions, CompressionType.None);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ public partial class ZipReader : AbstractReader<ZipEntry, ZipVolume>
|
|||
/// Opens a ZipReader for Non-seeking usage with a single volume
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="readerOptions"></param>
|
||||
/// <returns></returns>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options = null)
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new ZipReader(stream, options ?? new ReaderOptions());
|
||||
return new ZipReader(stream, readerOptions ?? new ReaderOptions());
|
||||
}
|
||||
|
||||
public static IReader OpenReader(
|
||||
|
|
|
|||
71
src/SharpCompress/ThrowHelper.cs
Normal file
71
src/SharpCompress/ThrowHelper.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace SharpCompress;
|
||||
|
||||
internal static class ThrowHelper
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNull([NotNull] object? argument, string? paramName = null)
|
||||
{
|
||||
if (argument is null)
|
||||
{
|
||||
throw new ArgumentNullException(paramName);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNegative(int value, string? paramName = null)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(paramName);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNegative(long value, string? paramName = null)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(paramName);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNegativeOrZero(int value, string? paramName = null)
|
||||
{
|
||||
if (value <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(paramName);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfLessThan(int value, int other, string? paramName = null)
|
||||
{
|
||||
if (value < other)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(paramName);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfGreaterThan(int value, int other, string? paramName = null)
|
||||
{
|
||||
if (value > other)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(paramName);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfGreaterThan(uint value, uint other, string? paramName = null)
|
||||
{
|
||||
if (value > other)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(paramName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,13 +26,10 @@ internal static partial class Utility
|
|||
throw new ArgumentNullException();
|
||||
}
|
||||
#else
|
||||
ArgumentNullException.ThrowIfNull(source);
|
||||
ThrowHelper.ThrowIfNull(source);
|
||||
#endif
|
||||
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
|
||||
if (offset < 0 || offset > buffer.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -253,13 +253,10 @@ internal static partial class Utility
|
|||
throw new ArgumentNullException();
|
||||
}
|
||||
#else
|
||||
ArgumentNullException.ThrowIfNull(source);
|
||||
ThrowHelper.ThrowIfNull(source);
|
||||
#endif
|
||||
|
||||
if (buffer is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ThrowHelper.ThrowIfNull(buffer);
|
||||
|
||||
if (offset < 0 || offset > buffer.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ public partial class GZipWriter : IWriterOpenable<GZipWriterOptions>
|
|||
return new GZipWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(string path, GZipWriterOptions writerOptions)
|
||||
public static IAsyncWriter OpenAsyncWriter(string stream, GZipWriterOptions writerOptions)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(path, writerOptions);
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(Stream stream, GZipWriterOptions writerOptions)
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ public partial class TarWriter : IWriterOpenable<TarWriterOptions>
|
|||
return new TarWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(string path, TarWriterOptions writerOptions)
|
||||
public static IAsyncWriter OpenAsyncWriter(string stream, TarWriterOptions writerOptions)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(path, writerOptions);
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(Stream stream, TarWriterOptions writerOptions)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public partial class ZipWriter
|
|||
/// Asynchronously writes an entry to the ZIP archive.
|
||||
/// </summary>
|
||||
public override async ValueTask WriteAsync(
|
||||
string entryPath,
|
||||
string filename,
|
||||
Stream source,
|
||||
DateTime? modificationTime,
|
||||
CancellationToken cancellationToken = default
|
||||
|
|
@ -22,7 +22,7 @@ public partial class ZipWriter
|
|||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
await WriteAsync(
|
||||
entryPath,
|
||||
filename,
|
||||
source,
|
||||
new ZipWriterEntryOptions { ModificationDateTime = modificationTime },
|
||||
cancellationToken
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ public partial class ZipWriter : IWriterOpenable<ZipWriterOptions>
|
|||
return new ZipWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(string path, ZipWriterOptions writerOptions)
|
||||
public static IAsyncWriter OpenAsyncWriter(string stream, ZipWriterOptions writerOptions)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(path, writerOptions);
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(Stream stream, ZipWriterOptions writerOptions)
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@ public partial class ZipWriter : AbstractWriter
|
|||
_ => throw new InvalidFormatException("Invalid compression method: " + compressionType),
|
||||
};
|
||||
|
||||
public override void Write(string entryPath, Stream source, DateTime? modificationTime) =>
|
||||
public override void Write(string filename, Stream source, DateTime? modificationTime) =>
|
||||
Write(
|
||||
entryPath,
|
||||
filename,
|
||||
source,
|
||||
new ZipWriterEntryOptions() { ModificationDateTime = modificationTime }
|
||||
);
|
||||
|
|
|
|||
|
|
@ -85,10 +85,7 @@ public class LargeMemoryStream : Stream
|
|||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(buffer);
|
||||
|
||||
if (offset < 0 || count < 0 || offset + count > buffer.Length)
|
||||
{
|
||||
|
|
@ -130,10 +127,7 @@ public class LargeMemoryStream : Stream
|
|||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(buffer);
|
||||
|
||||
if (offset < 0 || count < 0 || offset + count > buffer.Length)
|
||||
{
|
||||
|
|
@ -292,10 +286,7 @@ public class LargeMemoryStream : Stream
|
|||
|
||||
private void ThrowIfDisposed()
|
||||
{
|
||||
if (_isDisposed)
|
||||
{
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
}
|
||||
ObjectDisposedException.ThrowIf(_isDisposed, this);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,12 @@ public class WriterTests : TestBase
|
|||
|
||||
writerOptions.ArchiveEncoding.Default = encoding ?? Encoding.Default;
|
||||
|
||||
using var writer = WriterFactory.OpenAsyncWriter(stream, _type, writerOptions);
|
||||
using var writer = WriterFactory.OpenAsyncWriter(
|
||||
stream,
|
||||
_type,
|
||||
writerOptions,
|
||||
cancellationToken
|
||||
);
|
||||
await writer.WriteAllAsync(
|
||||
ORIGINAL_FILES_PATH,
|
||||
"*",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue