mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-07-09 02:26:47 +00:00
Merge pull request #1295 from adamhathcock/adam/fix-opening
Fix usage of ReaderOptions and pre-defined values
This commit is contained in:
@@ -40,7 +40,7 @@ public abstract partial class AbstractArchive<TEntry, TVolume> : IArchive, IAsyn
|
||||
internal AbstractArchive(ArchiveType type)
|
||||
{
|
||||
Type = type;
|
||||
ReaderOptions = new();
|
||||
ReaderOptions = ReaderOptions.Default;
|
||||
_lazyVolumes = new LazyReadOnlyCollection<TVolume>(Enumerable.Empty<TVolume>());
|
||||
_lazyEntries = new LazyReadOnlyCollection<TEntry>(Enumerable.Empty<TEntry>());
|
||||
_lazyVolumesAsync = new LazyAsyncReadOnlyCollection<TVolume>(
|
||||
|
||||
@@ -33,7 +33,11 @@ public static partial class ArchiveFactory
|
||||
)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenAsyncArchive(new FileInfo(filePath), options, cancellationToken);
|
||||
return OpenAsyncArchive(
|
||||
new FileInfo(filePath),
|
||||
options ?? ReaderOptions.ForFilePath,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
public static async ValueTask<IAsyncArchive> OpenAsyncArchive(
|
||||
|
||||
@@ -37,7 +37,7 @@ public static partial class ArchiveFactory
|
||||
public static IArchive OpenArchive(string filePath, ReaderOptions? options = null)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenArchive(new FileInfo(filePath), options);
|
||||
return OpenArchive(new FileInfo(filePath), options ?? ReaderOptions.ForFilePath);
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(FileInfo fileInfo, ReaderOptions? options = null)
|
||||
|
||||
@@ -15,18 +15,17 @@ namespace SharpCompress.Archives.Rar;
|
||||
internal class FileInfoRarArchiveVolume : RarVolume
|
||||
{
|
||||
internal FileInfoRarArchiveVolume(FileInfo fileInfo, ReaderOptions options, int index)
|
||||
: base(StreamingMode.Seekable, fileInfo.OpenRead(), FixOptions(options), index)
|
||||
: base(
|
||||
StreamingMode.Seekable,
|
||||
fileInfo.OpenRead(),
|
||||
options.WithLeaveStreamOpen(false),
|
||||
index
|
||||
)
|
||||
{
|
||||
FileInfo = fileInfo;
|
||||
FileParts = GetVolumeFileParts().ToArray().ToReadOnly();
|
||||
}
|
||||
|
||||
private static ReaderOptions FixOptions(ReaderOptions options)
|
||||
{
|
||||
//make sure we're closing streams with fileinfo
|
||||
return options with { LeaveStreamOpen = false };
|
||||
}
|
||||
|
||||
internal ReadOnlyCollection<RarFilePart> FileParts { get; }
|
||||
|
||||
internal FileInfo FileInfo { get; }
|
||||
|
||||
@@ -51,7 +51,7 @@ public partial class RarArchive
|
||||
new SourceStream(
|
||||
fileInfo,
|
||||
i => RarArchiveVolumeFactory.GetFilePart(i, fileInfo),
|
||||
readerOptions ?? new ReaderOptions()
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public partial class RarArchive
|
||||
}
|
||||
|
||||
return new RarArchive(
|
||||
new SourceStream(stream, _ => null, readerOptions ?? new ReaderOptions())
|
||||
new SourceStream(stream, _ => null, readerOptions ?? ReaderOptions.ForExternalStream)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public partial class ZipArchive
|
||||
s = new SourceStream(
|
||||
v[0].Stream,
|
||||
i => i < v.Length ? v[i].Stream : null,
|
||||
new ReaderOptions() { LeaveStreamOpen = true }
|
||||
ReaderOptions.ForExternalStream
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -86,7 +86,7 @@ public partial class ZipArchive
|
||||
s = new SourceStream(
|
||||
v[0].Stream,
|
||||
i => i < v.Length ? v[i].Stream : null,
|
||||
new ReaderOptions() { LeaveStreamOpen = true }
|
||||
ReaderOptions.ForExternalStream
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -90,15 +90,7 @@ internal static partial class ExtractionMethods
|
||||
options ??= new ExtractionOptions();
|
||||
if (entry.LinkTarget != null)
|
||||
{
|
||||
if (options.SymbolicLinkHandler is not null)
|
||||
{
|
||||
options.SymbolicLinkHandler(destinationFileName, entry.LinkTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExtractionOptions.DefaultSymbolicLinkHandler(destinationFileName, entry.LinkTarget);
|
||||
}
|
||||
return;
|
||||
options.SymbolicLinkHandler?.Invoke(destinationFileName, entry.LinkTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -99,15 +99,7 @@ internal static partial class ExtractionMethods
|
||||
options ??= new ExtractionOptions();
|
||||
if (entry.LinkTarget != null)
|
||||
{
|
||||
if (options.SymbolicLinkHandler is not null)
|
||||
{
|
||||
options.SymbolicLinkHandler(destinationFileName, entry.LinkTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExtractionOptions.DefaultSymbolicLinkHandler(destinationFileName, entry.LinkTarget);
|
||||
}
|
||||
return;
|
||||
options.SymbolicLinkHandler?.Invoke(destinationFileName, entry.LinkTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ public sealed record ExtractionOptions : IExtractionOptions
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <b>Breaking change:</b> Changed from field to init-only property in version 0.40.0.
|
||||
/// The default handler logs a warning message.
|
||||
/// If no handler is provided, symbolic links are silently skipped during extraction.
|
||||
/// </remarks>
|
||||
public Action<string, string>? SymbolicLinkHandler { get; init; }
|
||||
|
||||
@@ -58,10 +58,7 @@ public sealed record ExtractionOptions : IExtractionOptions
|
||||
/// Creates a new ExtractionOptions instance with the specified overwrite behavior.
|
||||
/// </summary>
|
||||
/// <param name="overwrite">Whether to overwrite existing files.</param>
|
||||
public ExtractionOptions(bool overwrite)
|
||||
{
|
||||
Overwrite = overwrite;
|
||||
}
|
||||
public ExtractionOptions(bool overwrite) => Overwrite = overwrite;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new ExtractionOptions instance with the specified extraction path and overwrite behavior.
|
||||
@@ -102,14 +99,4 @@ public sealed record ExtractionOptions : IExtractionOptions
|
||||
/// </summary>
|
||||
public static ExtractionOptions PreserveMetadata =>
|
||||
new() { PreserveFileTime = true, PreserveAttributes = true };
|
||||
|
||||
/// <summary>
|
||||
/// Default symbolic link handler that logs a warning message.
|
||||
/// </summary>
|
||||
public static void DefaultSymbolicLinkHandler(string sourcePath, string targetPath)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"Could not write symlink {sourcePath} -> {targetPath}, for more information please see https://github.com/dotnet/runtime/issues/24271"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace SharpCompress.Common.GZip;
|
||||
|
||||
public class GZipVolume : Volume
|
||||
{
|
||||
public GZipVolume(Stream stream, ReaderOptions? options, int index)
|
||||
public GZipVolume(Stream stream, ReaderOptions options, int index)
|
||||
: base(stream, options, index) { }
|
||||
|
||||
public GZipVolume(FileInfo fileInfo, ReaderOptions options)
|
||||
: base(fileInfo.OpenRead(), options with { LeaveStreamOpen = false }) { }
|
||||
: base(fileInfo.OpenRead(), options.WithLeaveStreamOpen(false)) { }
|
||||
|
||||
public override bool IsFirstVolume => true;
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace SharpCompress.Common.Lzw;
|
||||
|
||||
public class LzwVolume : Volume
|
||||
{
|
||||
public LzwVolume(Stream stream, ReaderOptions? options, int index)
|
||||
public LzwVolume(Stream stream, ReaderOptions options, int index)
|
||||
: base(stream, options, index) { }
|
||||
|
||||
public LzwVolume(FileInfo fileInfo, ReaderOptions options)
|
||||
: base(fileInfo.OpenRead(), options with { LeaveStreamOpen = false }) { }
|
||||
: base(fileInfo.OpenRead(), options.WithLeaveStreamOpen(false)) { }
|
||||
|
||||
public override bool IsFirstVolume => true;
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ public abstract partial class Volume : IVolume, IAsyncDisposable
|
||||
private readonly Stream _baseStream;
|
||||
private readonly Stream _actualStream;
|
||||
|
||||
internal Volume(Stream stream, ReaderOptions? readerOptions, int index = 0)
|
||||
internal Volume(Stream stream, ReaderOptions readerOptions, int index = 0)
|
||||
{
|
||||
Index = index;
|
||||
ReaderOptions = readerOptions ?? new ReaderOptions();
|
||||
ReaderOptions = readerOptions;
|
||||
_baseStream = stream;
|
||||
|
||||
// Only rewind if it's a buffered SharpCompressStream (not passthrough)
|
||||
|
||||
@@ -317,7 +317,7 @@ public class TarFactory
|
||||
/// <inheritdoc/>
|
||||
public IReader OpenReader(Stream stream, ReaderOptions? options)
|
||||
{
|
||||
options ??= new ReaderOptions();
|
||||
options ??= ReaderOptions.ForExternalStream;
|
||||
var sharpCompressStream = new SharpCompressStream(stream);
|
||||
sharpCompressStream.StartRecording(TarWrapper.MaximumRewindBufferSize);
|
||||
foreach (var wrapper in TarWrapper.Wrappers)
|
||||
@@ -350,7 +350,7 @@ public class TarFactory
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
options ??= new ReaderOptions();
|
||||
options ??= ReaderOptions.ForExternalStream;
|
||||
var sharpCompressStream = new SharpCompressStream(stream);
|
||||
sharpCompressStream.StartRecording(TarWrapper.MaximumRewindBufferSize);
|
||||
foreach (var wrapper in TarWrapper.Wrappers)
|
||||
|
||||
@@ -20,7 +20,7 @@ public partial class AceReader
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new SingleVolumeAceReader(stream, readerOptions ?? new ReaderOptions());
|
||||
return new SingleVolumeAceReader(stream, readerOptions ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -32,7 +32,7 @@ public partial class AceReader
|
||||
public static IReader OpenReader(IEnumerable<Stream> streams, ReaderOptions? options = null)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
return new MultiVolumeAceReader(streams, options ?? new ReaderOptions());
|
||||
return new MultiVolumeAceReader(streams, options ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
@@ -62,7 +62,7 @@ public partial class AceReader
|
||||
)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
return new MultiVolumeAceReader(streams, options ?? new ReaderOptions());
|
||||
return new MultiVolumeAceReader(streams, options ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
|
||||
@@ -25,7 +25,7 @@ public partial class ArcReader : AbstractReader<ArcEntry, ArcVolume>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new ArcReader(stream, readerOptions ?? new ReaderOptions());
|
||||
return new ArcReader(stream, readerOptions ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
protected override IEnumerable<ArcEntry> GetEntries(Stream stream)
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract partial class ArjReader : AbstractReader<ArjEntry, ArjVolume>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new SingleVolumeArjReader(stream, readerOptions ?? new ReaderOptions());
|
||||
return new SingleVolumeArjReader(stream, readerOptions ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,7 +44,7 @@ public abstract partial class ArjReader : AbstractReader<ArjEntry, ArjVolume>
|
||||
public static IReader OpenReader(IEnumerable<Stream> streams, ReaderOptions? options = null)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
return new MultiVolumeArjReader(streams, options ?? new ReaderOptions());
|
||||
return new MultiVolumeArjReader(streams, options ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
protected abstract void ValidateArchive(ArjVolume archive);
|
||||
|
||||
@@ -56,6 +56,6 @@ public partial class GZipReader
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new GZipReader(stream, readerOptions ?? new ReaderOptions());
|
||||
return new GZipReader(stream, readerOptions ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,6 @@ public partial class LzwReader
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new LzwReader(stream, readerOptions ?? new ReaderOptions());
|
||||
return new LzwReader(stream, readerOptions ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract partial class RarReader : AbstractReader<RarReaderEntry, RarVolu
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new SingleVolumeRarReader(stream, readerOptions ?? new ReaderOptions());
|
||||
return new SingleVolumeRarReader(stream, readerOptions ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,7 +84,7 @@ public abstract partial class RarReader : AbstractReader<RarReaderEntry, RarVolu
|
||||
public static IReader OpenReader(IEnumerable<Stream> streams, ReaderOptions? options = null)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
return new MultiVolumeRarReader(streams, options ?? new ReaderOptions());
|
||||
return new MultiVolumeRarReader(streams, options ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
protected override IEnumerable<RarReaderEntry> GetEntries(Stream stream)
|
||||
|
||||
@@ -25,7 +25,11 @@ public static partial class ReaderFactory
|
||||
)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenAsyncReader(new FileInfo(filePath), options, cancellationToken);
|
||||
return OpenAsyncReader(
|
||||
new FileInfo(filePath),
|
||||
options ?? ReaderOptions.ForFilePath,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,7 +12,7 @@ public static partial class ReaderFactory
|
||||
public static IReader OpenReader(string filePath, ReaderOptions? options = null)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenReader(new FileInfo(filePath), options);
|
||||
return OpenReader(new FileInfo(filePath), options ?? ReaderOptions.ForFilePath);
|
||||
}
|
||||
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? options = null)
|
||||
|
||||
@@ -151,35 +151,34 @@ public sealed record ReaderOptions : IReaderOptions
|
||||
/// <summary>
|
||||
/// Gets ReaderOptions configured for caller-provided streams.
|
||||
/// </summary>
|
||||
public static ReaderOptions ForExternalStream => new() { LeaveStreamOpen = true };
|
||||
internal static ReaderOptions Default => new();
|
||||
|
||||
public static ReaderOptions ForExternalStream => Default.WithLeaveStreamOpen(true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets ReaderOptions configured for file-based overloads that open their own stream.
|
||||
/// </summary>
|
||||
public static ReaderOptions ForFilePath => new() { LeaveStreamOpen = false };
|
||||
public static ReaderOptions ForFilePath => Default;
|
||||
|
||||
/// <summary>
|
||||
/// Creates ReaderOptions for reading encrypted archives.
|
||||
/// </summary>
|
||||
/// <param name="password">The password for encrypted archives.</param>
|
||||
public static ReaderOptions ForEncryptedArchive(string? password = null) =>
|
||||
new ReaderOptions().WithPassword(password);
|
||||
Default.WithPassword(password);
|
||||
|
||||
/// <summary>
|
||||
/// Creates ReaderOptions for archives with custom character encoding.
|
||||
/// </summary>
|
||||
/// <param name="encoding">The encoding for archive entry names.</param>
|
||||
public static ReaderOptions ForEncoding(IArchiveEncoding encoding) =>
|
||||
new ReaderOptions().WithArchiveEncoding(encoding);
|
||||
Default.WithArchiveEncoding(encoding);
|
||||
|
||||
/// <summary>
|
||||
/// Creates ReaderOptions for self-extracting archives that require header search.
|
||||
/// </summary>
|
||||
public static ReaderOptions ForSelfExtractingArchive(string? password = null) =>
|
||||
new ReaderOptions()
|
||||
.WithLookForHeader(true)
|
||||
.WithPassword(password)
|
||||
.WithRewindableBufferSize(1_048_576); // 1MB for SFX archives
|
||||
Default.WithLookForHeader(true).WithPassword(password).WithRewindableBufferSize(1_048_576); // 1MB for SFX archives
|
||||
|
||||
// Note: Parameterized constructors have been removed.
|
||||
// Use fluent With*() helpers or object initializers instead:
|
||||
|
||||
@@ -89,7 +89,7 @@ public partial class TarReader
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
stream.NotNull(nameof(stream));
|
||||
readerOptions ??= new ReaderOptions();
|
||||
readerOptions ??= ReaderOptions.ForExternalStream;
|
||||
var sharpCompressStream = SharpCompressStream.Create(
|
||||
stream,
|
||||
bufferSize: Math.Max(
|
||||
@@ -171,7 +171,7 @@ public partial class TarReader
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
readerOptions ??= new ReaderOptions();
|
||||
readerOptions ??= ReaderOptions.ForExternalStream;
|
||||
var sharpCompressStream = SharpCompressStream.Create(
|
||||
stream,
|
||||
bufferSize: Math.Max(
|
||||
|
||||
@@ -48,7 +48,7 @@ public partial class ZipReader : AbstractReader<ZipEntry, ZipVolume>
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new ZipReader(stream, readerOptions ?? new ReaderOptions());
|
||||
return new ZipReader(stream, readerOptions ?? ReaderOptions.ForExternalStream);
|
||||
}
|
||||
|
||||
public static IReader OpenReader(
|
||||
@@ -58,7 +58,7 @@ public partial class ZipReader : AbstractReader<ZipEntry, ZipVolume>
|
||||
)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new ZipReader(stream, options ?? new ReaderOptions(), entries);
|
||||
return new ZipReader(stream, options ?? ReaderOptions.ForExternalStream, entries);
|
||||
}
|
||||
|
||||
#endregion Open
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Common.Options;
|
||||
using SharpCompress.Compressors;
|
||||
using SharpCompress.Providers;
|
||||
using D = SharpCompress.Compressors.Deflate;
|
||||
|
||||
@@ -18,17 +17,10 @@ namespace SharpCompress.Writers;
|
||||
/// </remarks>
|
||||
public sealed record WriterOptions : IWriterOptions
|
||||
{
|
||||
private CompressionType _compressionType;
|
||||
private int _compressionLevel;
|
||||
|
||||
/// <summary>
|
||||
/// The compression type to use for the archive.
|
||||
/// </summary>
|
||||
public CompressionType CompressionType
|
||||
{
|
||||
get => _compressionType;
|
||||
init => _compressionType = value;
|
||||
}
|
||||
public CompressionType CompressionType { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The compression level to be used when the compression type supports variable levels.
|
||||
@@ -40,11 +32,11 @@ public sealed record WriterOptions : IWriterOptions
|
||||
/// </summary>
|
||||
public int CompressionLevel
|
||||
{
|
||||
get => _compressionLevel;
|
||||
get;
|
||||
init
|
||||
{
|
||||
CompressionLevelValidation.Validate(CompressionType, value);
|
||||
_compressionLevel = value;
|
||||
field = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -268,9 +268,9 @@
|
||||
"net10.0": {
|
||||
"Microsoft.NET.ILLink.Tasks": {
|
||||
"type": "Direct",
|
||||
"requested": "[10.0.5, )",
|
||||
"resolved": "10.0.5",
|
||||
"contentHash": "A+5ZuQ0f449tM+MQrhf6R9ZX7lYpjk/ODEwLYKrnF6111rtARx8fVsm4YznUnQiKnnXfaXNBqgxmil6RW3L3SA=="
|
||||
"requested": "[10.0.0, )",
|
||||
"resolved": "10.0.0",
|
||||
"contentHash": "kICGrGYEzCNI3wPzfEXcwNHgTvlvVn9yJDhSdRK+oZQy4jvYH529u7O0xf5ocQKzOMjfS07+3z9PKRIjrFMJDA=="
|
||||
},
|
||||
"Microsoft.NETFramework.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
@@ -400,9 +400,9 @@
|
||||
"net8.0": {
|
||||
"Microsoft.NET.ILLink.Tasks": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.25, )",
|
||||
"resolved": "8.0.25",
|
||||
"contentHash": "sqX4nmBft05ivqKvUT4nxaN8rT3apCLt9SWFkfRrQPwra1zPwFknQAw1lleuMCKOCLvVmOWwrC2iPSm9RiXZUg=="
|
||||
"requested": "[8.0.22, )",
|
||||
"resolved": "8.0.22",
|
||||
"contentHash": "MhcMithKEiyyNkD2ZfbDZPmcOdi0GheGfg8saEIIEfD/fol3iHmcV8TsZkD4ZYz5gdUuoX4YtlVySUU7Sxl9SQ=="
|
||||
},
|
||||
"Microsoft.NETFramework.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
|
||||
@@ -70,7 +70,7 @@ public class TarBenchmarks : ArchiveBenchmarkBase
|
||||
using var stream = new MemoryStream(_tarBytes);
|
||||
using var archive = TarArchive.OpenArchive(
|
||||
stream,
|
||||
new ReaderOptions().WithProviders(
|
||||
ReaderOptions.ForExternalStream.WithProviders(
|
||||
CompressionProviderRegistry.Empty.With(new SystemGZipCompressionProvider())
|
||||
)
|
||||
);
|
||||
@@ -87,7 +87,7 @@ public class TarBenchmarks : ArchiveBenchmarkBase
|
||||
using var stream = new MemoryStream(_tarBytes);
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions().WithProviders(
|
||||
ReaderOptions.ForExternalStream.WithProviders(
|
||||
CompressionProviderRegistry.Empty.With(new SystemGZipCompressionProvider())
|
||||
)
|
||||
);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ZipBenchmarks : ArchiveBenchmarkBase
|
||||
using var stream = new MemoryStream(_archiveBytes);
|
||||
using var archive = ZipArchive.OpenArchive(
|
||||
stream,
|
||||
new ReaderOptions().WithProviders(
|
||||
ReaderOptions.ForExternalStream.WithProviders(
|
||||
CompressionProviderRegistry.Empty.With(new SystemDeflateCompressionProvider())
|
||||
)
|
||||
);
|
||||
@@ -73,7 +73,7 @@ public class ZipBenchmarks : ArchiveBenchmarkBase
|
||||
using var stream = new MemoryStream(_archiveBytes);
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions().WithProviders(
|
||||
ReaderOptions.ForExternalStream.WithProviders(
|
||||
CompressionProviderRegistry.Empty.With(new SystemDeflateCompressionProvider())
|
||||
)
|
||||
);
|
||||
|
||||
@@ -73,7 +73,7 @@ public class AceReaderAsyncTests : ReaderTests
|
||||
using Stream stream = File.OpenRead(testArchive);
|
||||
await using var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
new ReaderOptions()
|
||||
ReaderOptions.ForExternalStream
|
||||
);
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
{
|
||||
@@ -95,7 +95,10 @@ public class AceReaderAsyncTests : ReaderTests
|
||||
using Stream stream = File.OpenRead(testArchive);
|
||||
await using var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
);
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ArjReaderAsyncTests : ReaderTests
|
||||
using Stream stream = File.OpenRead(testArchive);
|
||||
await using var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
new ReaderOptions()
|
||||
ReaderOptions.ForExternalStream
|
||||
);
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
{
|
||||
@@ -119,7 +119,10 @@ public class ArjReaderAsyncTests : ReaderTests
|
||||
using Stream stream = File.OpenRead(testArchive);
|
||||
await using var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
new ReaderOptions() { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
);
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
{
|
||||
|
||||
@@ -332,7 +332,10 @@ public class CompressionProviderTests
|
||||
);
|
||||
|
||||
compressedStream.Position = 0;
|
||||
var readerOptions = new ReaderOptions { ArchiveEncoding = archiveEncoding };
|
||||
var readerOptions = ReaderOptions.ForExternalStream with
|
||||
{
|
||||
ArchiveEncoding = archiveEncoding,
|
||||
};
|
||||
var context = CompressionContext.FromStream(compressedStream) with
|
||||
{
|
||||
ReaderOptions = readerOptions,
|
||||
@@ -433,7 +436,7 @@ public class CompressionProviderTests
|
||||
archiveStream.Position = 0;
|
||||
var customProvider = new GZipCompressionProvider();
|
||||
var registry = CompressionProviderRegistry.Default.With(customProvider);
|
||||
var readOptions = new ReaderOptions { Providers = registry };
|
||||
var readOptions = ReaderOptions.ForExternalStream.WithProviders(registry);
|
||||
|
||||
using var reader = TarReader.OpenReader(archiveStream, readOptions);
|
||||
reader.MoveToNextEntry().Should().BeTrue();
|
||||
@@ -462,7 +465,7 @@ public class CompressionProviderTests
|
||||
|
||||
archiveStream.Position = 0;
|
||||
var registry = CompressionProviderRegistry.Default.With(new ContextRequiredGZipProvider());
|
||||
var readOptions = new ReaderOptions { Providers = registry };
|
||||
var readOptions = ReaderOptions.ForExternalStream.WithProviders(registry);
|
||||
|
||||
using var reader = TarReader.OpenReader(archiveStream, readOptions);
|
||||
reader.MoveToNextEntry().Should().BeTrue();
|
||||
@@ -504,7 +507,11 @@ public class CompressionProviderTests
|
||||
var customProvider = new DeflateCompressionProvider();
|
||||
var registry = CompressionProviderRegistry.Default.With(customProvider);
|
||||
|
||||
var original = new ReaderOptions { Providers = registry, LeaveStreamOpen = false };
|
||||
var original = ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Providers = registry,
|
||||
LeaveStreamOpen = false,
|
||||
};
|
||||
|
||||
// Clone using 'with' expression
|
||||
var clone = original with
|
||||
@@ -533,7 +540,7 @@ public class CompressionProviderTests
|
||||
|
||||
var trackingProvider = new TrackingCompressionProvider(new GZipCompressionProvider());
|
||||
var registry = CompressionProviderRegistry.Default.With(trackingProvider);
|
||||
var readOptions = new ReaderOptions { Providers = registry };
|
||||
var readOptions = ReaderOptions.ForExternalStream.WithProviders(registry);
|
||||
|
||||
archiveStream.Position = 0;
|
||||
using var archive = TarArchive.OpenArchive(archiveStream, readOptions);
|
||||
@@ -562,7 +569,7 @@ public class CompressionProviderTests
|
||||
|
||||
var trackingProvider = new TrackingCompressionProvider(new GZipCompressionProvider());
|
||||
var registry = CompressionProviderRegistry.Default.With(trackingProvider);
|
||||
var readOptions = new ReaderOptions { Providers = registry };
|
||||
var readOptions = ReaderOptions.ForExternalStream.WithProviders(registry);
|
||||
|
||||
archiveStream.Position = 0;
|
||||
await using var archive = await TarArchive.OpenAsyncArchive(archiveStream, readOptions);
|
||||
@@ -600,7 +607,7 @@ public class CompressionProviderTests
|
||||
|
||||
var trackingProvider = new TrackingCompressionProvider(new DeflateCompressionProvider());
|
||||
var registry = CompressionProviderRegistry.Default.With(trackingProvider);
|
||||
var options = new ReaderOptions { Providers = registry };
|
||||
var options = ReaderOptions.ForExternalStream.WithProviders(registry);
|
||||
|
||||
zipStream.Position = 0;
|
||||
await using var reader = await ReaderFactory.OpenAsyncReader(zipStream, options);
|
||||
@@ -618,7 +625,7 @@ public class CompressionProviderTests
|
||||
var archivePath = Path.Combine(TestBase.TEST_ARCHIVES_PATH, "Tar.tar.Z");
|
||||
var trackingProvider = new TrackingCompressionProvider(new LzwCompressionProvider());
|
||||
var registry = CompressionProviderRegistry.Default.With(trackingProvider);
|
||||
var options = new ReaderOptions { Providers = registry };
|
||||
var options = ReaderOptions.ForExternalStream.WithProviders(registry);
|
||||
|
||||
using var stream = File.OpenRead(archivePath);
|
||||
using var reader = ReaderFactory.OpenReader(stream, options);
|
||||
@@ -809,7 +816,7 @@ public class CompressionProviderTests
|
||||
|
||||
// Read back using internal provider (should be compatible)
|
||||
archiveStream.Position = 0;
|
||||
var readOptions = new ReaderOptions();
|
||||
var readOptions = ReaderOptions.ForExternalStream;
|
||||
using var reader = TarReader.OpenReader(archiveStream, readOptions);
|
||||
reader.MoveToNextEntry().Should().BeTrue();
|
||||
using var entryStream = reader.OpenEntryStream();
|
||||
|
||||
@@ -37,7 +37,10 @@ public class LzwReaderTests : ReaderTests
|
||||
using Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.Z"));
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LeaveStreamOpen = false }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LeaveStreamOpen = false,
|
||||
}
|
||||
);
|
||||
|
||||
// Should detect as Tar archive with Lzw compression
|
||||
|
||||
@@ -160,8 +160,8 @@ public class OptionsUsabilityTests : TestBase
|
||||
[Fact]
|
||||
public void ReaderOptions_Fluent_Methods_Modify_Correctly()
|
||||
{
|
||||
var options = new ReaderOptions()
|
||||
.WithLeaveStreamOpen(false)
|
||||
var options = ReaderOptions
|
||||
.ForExternalStream.WithLeaveStreamOpen(false)
|
||||
.WithPassword("secret")
|
||||
.WithLookForHeader(true)
|
||||
.WithBufferSize(65536);
|
||||
@@ -176,15 +176,15 @@ public class OptionsUsabilityTests : TestBase
|
||||
public void ReaderOptions_Fluent_And_Initializer_Equivalent()
|
||||
{
|
||||
// Fluent approach
|
||||
var fluentApproach = new ReaderOptions()
|
||||
.WithLeaveStreamOpen(false)
|
||||
var fluentApproach = ReaderOptions
|
||||
.ForExternalStream.WithLeaveStreamOpen(false)
|
||||
.WithPassword("secret")
|
||||
.WithLookForHeader(true)
|
||||
.WithBufferSize(65536)
|
||||
.WithDisableCheckIncomplete(true);
|
||||
|
||||
// Object initializer approach
|
||||
var initializerApproach = new ReaderOptions
|
||||
// Preset + with-expression approach
|
||||
var initializerApproach = ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LeaveStreamOpen = false,
|
||||
Password = "secret",
|
||||
|
||||
@@ -108,7 +108,7 @@ public class ProgressReportTests : TestBase
|
||||
|
||||
// Now read it with progress reporting
|
||||
archiveStream.Position = 0;
|
||||
var readerOptions = new ReaderOptions { Progress = progress };
|
||||
var readerOptions = ReaderOptions.ForExternalStream.WithProgress(progress);
|
||||
|
||||
using (var reader = ReaderFactory.OpenReader(archiveStream, readerOptions))
|
||||
{
|
||||
@@ -234,7 +234,7 @@ public class ProgressReportTests : TestBase
|
||||
|
||||
// Read without progress
|
||||
archiveStream.Position = 0;
|
||||
var readerOptions = new ReaderOptions();
|
||||
var readerOptions = ReaderOptions.ForExternalStream;
|
||||
Assert.Null(readerOptions.Progress);
|
||||
|
||||
using (var reader = ReaderFactory.OpenReader(archiveStream, readerOptions))
|
||||
@@ -324,7 +324,7 @@ public class ProgressReportTests : TestBase
|
||||
|
||||
// Now read it with progress reporting
|
||||
archiveStream.Position = 0;
|
||||
var readerOptions = new ReaderOptions { Progress = progress };
|
||||
var readerOptions = ReaderOptions.ForExternalStream.WithProgress(progress);
|
||||
|
||||
using (var reader = ReaderFactory.OpenReader(archiveStream, readerOptions))
|
||||
{
|
||||
@@ -445,7 +445,7 @@ public class ProgressReportTests : TestBase
|
||||
|
||||
// Now read it with progress reporting
|
||||
archiveStream.Position = 0;
|
||||
var readerOptions = new ReaderOptions { Progress = progress };
|
||||
var readerOptions = ReaderOptions.ForExternalStream.WithProgress(progress);
|
||||
|
||||
using (var reader = ReaderFactory.OpenReader(archiveStream, readerOptions))
|
||||
{
|
||||
@@ -538,7 +538,7 @@ public class ProgressReportTests : TestBase
|
||||
|
||||
// Now read it with progress reporting
|
||||
archiveStream.Position = 0;
|
||||
var readerOptions = new ReaderOptions { Progress = progress };
|
||||
var readerOptions = ReaderOptions.ForExternalStream.WithProgress(progress);
|
||||
|
||||
await using (
|
||||
var reader = await ReaderFactory.OpenAsyncReader(
|
||||
|
||||
@@ -71,7 +71,11 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
await using (
|
||||
var archive = await RarArchive.OpenAsyncArchive(
|
||||
stream,
|
||||
new ReaderOptions { Password = password, LeaveStreamOpen = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = password,
|
||||
LeaveStreamOpen = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -98,7 +102,11 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, archiveName),
|
||||
new ReaderOptions { Password = password, LeaveStreamOpen = true }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = password,
|
||||
LeaveStreamOpen = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -144,7 +152,13 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
{
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg"));
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(stream, new ReaderOptions { LookForHeader = true })
|
||||
var archive = RarArchive.OpenArchive(
|
||||
stream,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
@@ -316,7 +330,10 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg"),
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
@@ -66,7 +66,11 @@ public class RarArchiveTests : ArchiveTests
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(
|
||||
stream,
|
||||
new ReaderOptions { Password = password, LeaveStreamOpen = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = password,
|
||||
LeaveStreamOpen = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -93,7 +97,11 @@ public class RarArchiveTests : ArchiveTests
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, archiveName),
|
||||
new ReaderOptions { Password = password, LeaveStreamOpen = true }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = password,
|
||||
LeaveStreamOpen = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -136,7 +144,13 @@ public class RarArchiveTests : ArchiveTests
|
||||
{
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg"));
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(stream, new ReaderOptions { LookForHeader = true })
|
||||
var archive = RarArchive.OpenArchive(
|
||||
stream,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
@@ -302,7 +316,10 @@ public class RarArchiveTests : ArchiveTests
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg"),
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -751,7 +768,7 @@ public class RarArchiveTests : ArchiveTests
|
||||
public void Rar_MalformedArchive_NoInfiniteLoop()
|
||||
{
|
||||
var testFile = "Rar.malformed_512byte.rar";
|
||||
var readerOptions = new ReaderOptions { LookForHeader = true };
|
||||
var readerOptions = ReaderOptions.ForExternalStream.WithLookForHeader(true);
|
||||
|
||||
// This should throw InvalidOperationException, not hang in an infinite loop
|
||||
var exception = Assert.Throws<ArchiveOperationException>(() =>
|
||||
|
||||
@@ -16,7 +16,10 @@ public class RarHeaderFactoryTest : TestBase
|
||||
public RarHeaderFactoryTest() =>
|
||||
_rarHeaderFactory = new RarHeaderFactory(
|
||||
StreamingMode.Seekable,
|
||||
new ReaderOptions { LeaveStreamOpen = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LeaveStreamOpen = true,
|
||||
}
|
||||
);
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -73,7 +73,10 @@ public class RarReaderAsyncTests : ReaderTests
|
||||
archives
|
||||
.Select(s => Path.Combine(TEST_ARCHIVES_PATH, s))
|
||||
.Select(p => File.OpenRead(p)),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -187,7 +190,10 @@ public class RarReaderAsyncTests : ReaderTests
|
||||
await ReadAsync(
|
||||
testArchive,
|
||||
CompressionType.Rar,
|
||||
new ReaderOptions { Password = password }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = password,
|
||||
}
|
||||
);
|
||||
|
||||
[Fact]
|
||||
@@ -248,7 +254,10 @@ public class RarReaderAsyncTests : ReaderTests
|
||||
await using (
|
||||
var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -271,7 +280,10 @@ public class RarReaderAsyncTests : ReaderTests
|
||||
using (
|
||||
IReader baseReader = RarReader.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -314,7 +326,10 @@ public class RarReaderAsyncTests : ReaderTests
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, filename));
|
||||
await using var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
);
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
{
|
||||
@@ -337,7 +352,10 @@ public class RarReaderAsyncTests : ReaderTests
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, filename));
|
||||
await using var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
);
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
{
|
||||
@@ -359,7 +377,7 @@ public class RarReaderAsyncTests : ReaderTests
|
||||
using Stream stream = File.OpenRead(testArchive);
|
||||
await using var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
readerOptions ?? new ReaderOptions()
|
||||
readerOptions ?? ReaderOptions.ForExternalStream
|
||||
);
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
{
|
||||
|
||||
@@ -71,7 +71,10 @@ public class RarReaderTests : ReaderTests
|
||||
archives
|
||||
.Select(s => Path.Combine(TEST_ARCHIVES_PATH, s))
|
||||
.Select(p => File.OpenRead(p)),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -173,7 +176,14 @@ public class RarReaderTests : ReaderTests
|
||||
public void Rar5_Encrypted_Reader() => ReadRar("Rar5.encrypted_filesOnly.rar", "test");
|
||||
|
||||
private void ReadRar(string testArchive, string password) =>
|
||||
Read(testArchive, CompressionType.Rar, new ReaderOptions { Password = password });
|
||||
Read(
|
||||
testArchive,
|
||||
CompressionType.Rar,
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = password,
|
||||
}
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void Rar_Entry_Stream() => DoRar_Entry_Stream("Rar.rar");
|
||||
@@ -222,7 +232,10 @@ public class RarReaderTests : ReaderTests
|
||||
using (
|
||||
var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -243,7 +256,13 @@ public class RarReaderTests : ReaderTests
|
||||
{
|
||||
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg")))
|
||||
using (
|
||||
var reader = RarReader.OpenReader(stream, new ReaderOptions { LookForHeader = true })
|
||||
var reader = RarReader.OpenReader(
|
||||
stream,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
@@ -278,7 +297,10 @@ public class RarReaderTests : ReaderTests
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, filename));
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
);
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
@@ -301,7 +323,10 @@ public class RarReaderTests : ReaderTests
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, filename));
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
);
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
@@ -321,7 +346,10 @@ public class RarReaderTests : ReaderTests
|
||||
);
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
);
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
|
||||
@@ -32,12 +32,12 @@ public abstract class ReaderTests : TestBase
|
||||
)
|
||||
{
|
||||
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
|
||||
options ??= new ReaderOptions { BufferSize = 0x20000 };
|
||||
options ??= ReaderOptions.ForFilePath.WithBufferSize(0x20000);
|
||||
|
||||
var optionsWithStreamOpen = options with { LeaveStreamOpen = true };
|
||||
var optionsWithStreamOpen = options.WithLeaveStreamOpen(true);
|
||||
readImpl(testArchive, optionsWithStreamOpen);
|
||||
|
||||
var optionsWithStreamClosed = options with { LeaveStreamOpen = false };
|
||||
var optionsWithStreamClosed = options.WithLeaveStreamOpen(false);
|
||||
readImpl(testArchive, optionsWithStreamClosed);
|
||||
|
||||
VerifyFiles();
|
||||
@@ -128,9 +128,9 @@ public abstract class ReaderTests : TestBase
|
||||
{
|
||||
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
|
||||
|
||||
options ??= new ReaderOptions() { BufferSize = 0x20000 };
|
||||
options ??= ReaderOptions.ForExternalStream.WithBufferSize(0x20000);
|
||||
|
||||
var optionsWithStreamOpen = options with { LeaveStreamOpen = true };
|
||||
var optionsWithStreamOpen = options.WithLeaveStreamOpen(true);
|
||||
await ReadImplAsync(
|
||||
testArchive,
|
||||
expectedCompression,
|
||||
@@ -138,7 +138,7 @@ public abstract class ReaderTests : TestBase
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
var optionsWithStreamClosed = options with { LeaveStreamOpen = false };
|
||||
var optionsWithStreamClosed = options.WithLeaveStreamOpen(false);
|
||||
await ReadImplAsync(
|
||||
testArchive,
|
||||
expectedCompression,
|
||||
@@ -215,7 +215,10 @@ public abstract class ReaderTests : TestBase
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, fileName));
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = true,
|
||||
}
|
||||
);
|
||||
|
||||
while (reader.MoveToNextEntry())
|
||||
|
||||
@@ -27,16 +27,28 @@ public class SevenZipArchiveTests : ArchiveTests
|
||||
|
||||
[Fact]
|
||||
public void SevenZipArchive_LZMAAES_StreamRead() =>
|
||||
ArchiveStreamRead("7Zip.LZMA.Aes.7z", new ReaderOptions { Password = "testpassword" });
|
||||
ArchiveStreamRead(
|
||||
"7Zip.LZMA.Aes.7z",
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "testpassword",
|
||||
}
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void SevenZipArchive_LZMAAES_PathRead() =>
|
||||
ArchiveFileRead("7Zip.LZMA.Aes.7z", new ReaderOptions { Password = "testpassword" });
|
||||
ArchiveFileRead(
|
||||
"7Zip.LZMA.Aes.7z",
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "testpassword",
|
||||
}
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void SevenZipArchive_LZMAAES_NoPasswordExceptionTest() =>
|
||||
Assert.Throws<CryptographicException>(() =>
|
||||
ArchiveFileRead("7Zip.LZMA.Aes.7z", new ReaderOptions { Password = null })
|
||||
ArchiveFileRead("7Zip.LZMA.Aes.7z", ReaderOptions.ForFilePath.WithPassword(null))
|
||||
); //was failing with ArgumentNullException not CryptographicException like rar
|
||||
|
||||
[Fact]
|
||||
@@ -57,19 +69,39 @@ public class SevenZipArchiveTests : ArchiveTests
|
||||
|
||||
[Fact]
|
||||
public void SevenZipArchive_LZMA2_EXE_StreamRead() =>
|
||||
ArchiveStreamRead(new SevenZipFactory(), "7Zip.LZMA2.exe", new() { LookForHeader = true });
|
||||
ArchiveStreamRead(
|
||||
new SevenZipFactory(),
|
||||
"7Zip.LZMA2.exe",
|
||||
ReaderOptions.ForExternalStream.WithLookForHeader(true)
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void SevenZipArchive_LZMA2_EXE_PathRead() =>
|
||||
ArchiveFileRead("7Zip.LZMA2.exe", new() { LookForHeader = true }, new SevenZipFactory());
|
||||
ArchiveFileRead(
|
||||
"7Zip.LZMA2.exe",
|
||||
ReaderOptions.ForFilePath.WithLookForHeader(true),
|
||||
new SevenZipFactory()
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void SevenZipArchive_LZMA2AES_StreamRead() =>
|
||||
ArchiveStreamRead("7Zip.LZMA2.Aes.7z", new ReaderOptions { Password = "testpassword" });
|
||||
ArchiveStreamRead(
|
||||
"7Zip.LZMA2.Aes.7z",
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "testpassword",
|
||||
}
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void SevenZipArchive_LZMA2AES_PathRead() =>
|
||||
ArchiveFileRead("7Zip.LZMA2.Aes.7z", new ReaderOptions { Password = "testpassword" });
|
||||
ArchiveFileRead(
|
||||
"7Zip.LZMA2.Aes.7z",
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "testpassword",
|
||||
}
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void SevenZipArchive_BZip2_StreamRead() => ArchiveStreamRead("7Zip.BZip2.7z");
|
||||
|
||||
@@ -76,7 +76,10 @@ public class DisposalTests
|
||||
new SourceStream(
|
||||
stream,
|
||||
i => null,
|
||||
new ReaderOptions { LeaveStreamOpen = leaveOpen }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LeaveStreamOpen = leaveOpen,
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class TarArchiveAsyncTests : ArchiveTests
|
||||
await using (
|
||||
var archive2 = await TarArchive.OpenAsyncArchive(
|
||||
new AsyncOnlyStream(File.OpenRead(unmodified)),
|
||||
new ReaderOptions() { LeaveStreamOpen = false }
|
||||
ReaderOptions.ForExternalStream.WithLeaveStreamOpen(false)
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ public class TarArchiveAsyncTests : ArchiveTests
|
||||
await using (
|
||||
var archive2 = await TarArchive.OpenAsyncArchive(
|
||||
new AsyncOnlyStream(File.OpenRead(unmodified)),
|
||||
new ReaderOptions() { LeaveStreamOpen = false }
|
||||
ReaderOptions.ForExternalStream.WithLeaveStreamOpen(false)
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -213,7 +213,7 @@ public class TarArchiveAsyncTests : ArchiveTests
|
||||
}
|
||||
using (var inputMemory = new MemoryStream(mstm.ToArray()))
|
||||
{
|
||||
var tropt = new ReaderOptions { ArchiveEncoding = enc };
|
||||
var tropt = ReaderOptions.ForExternalStream.WithArchiveEncoding(enc);
|
||||
await using (
|
||||
var tr = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(inputMemory),
|
||||
|
||||
@@ -262,7 +262,7 @@ public class TarArchiveTests : ArchiveTests
|
||||
}
|
||||
using (var inputMemory = new MemoryStream(mstm.ToArray()))
|
||||
{
|
||||
var tropt = new ReaderOptions { ArchiveEncoding = enc };
|
||||
var tropt = ReaderOptions.ForExternalStream.WithArchiveEncoding(enc);
|
||||
using (var tr = TarReader.OpenReader(inputMemory, tropt))
|
||||
{
|
||||
while (tr.MoveToNextEntry())
|
||||
|
||||
@@ -255,7 +255,7 @@ public class TestBase : IAsyncDisposable
|
||||
|
||||
protected void CompareArchivesByPath(string file1, string file2, Encoding? encoding = null)
|
||||
{
|
||||
var readerOptions = new ReaderOptions { LeaveStreamOpen = false };
|
||||
var readerOptions = ReaderOptions.ForExternalStream.WithLeaveStreamOpen(false);
|
||||
readerOptions.ArchiveEncoding.Default = encoding ?? Encoding.Default;
|
||||
|
||||
//don't compare the order. OS X reads files from the file system in a different order therefore makes the archive ordering different
|
||||
|
||||
@@ -39,7 +39,7 @@ public class WriterTests : TestBase
|
||||
|
||||
using (Stream stream = File.OpenRead(Path.Combine(SCRATCH2_FILES_PATH, archive)))
|
||||
{
|
||||
var readerOptions = new ReaderOptions();
|
||||
var readerOptions = ReaderOptions.ForExternalStream;
|
||||
|
||||
readerOptions.ArchiveEncoding.Default = encoding ?? Encoding.Default;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class WriterTests : TestBase
|
||||
|
||||
using (Stream stream = File.OpenRead(Path.Combine(SCRATCH2_FILES_PATH, archive)))
|
||||
{
|
||||
var readerOptions = new ReaderOptions();
|
||||
var readerOptions = ReaderOptions.ForExternalStream;
|
||||
|
||||
readerOptions.ArchiveEncoding.Default = encoding ?? Encoding.Default;
|
||||
|
||||
|
||||
@@ -201,7 +201,10 @@ public class Zip64AsyncTests : WriterTests
|
||||
{
|
||||
await using var rd = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(fs),
|
||||
new ReaderOptions { LookForHeader = false }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = false,
|
||||
}
|
||||
);
|
||||
while (await rd.MoveToNextEntryAsync())
|
||||
{
|
||||
|
||||
@@ -182,7 +182,15 @@ public class Zip64Tests : WriterTests
|
||||
long size = 0;
|
||||
IEntry? prev = null;
|
||||
using (var fs = File.OpenRead(filename))
|
||||
using (var rd = ZipReader.OpenReader(fs, new ReaderOptions { LookForHeader = false }))
|
||||
using (
|
||||
var rd = ZipReader.OpenReader(
|
||||
fs,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LookForHeader = false,
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
while (rd.MoveToNextEntry())
|
||||
{
|
||||
|
||||
@@ -465,7 +465,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
using (
|
||||
var reader = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.WinzipAES.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -482,7 +485,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
{
|
||||
using var reader = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.WinzipAES2.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
foreach (var entry in reader.Entries.Where(x => !x.IsDirectory))
|
||||
{
|
||||
@@ -499,7 +505,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
// Test that WinZip AES encrypted entries correctly report their compression type
|
||||
using var deflateArchive = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.WinzipAES.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
foreach (var entry in deflateArchive.Entries.Where(x => !x.IsDirectory))
|
||||
{
|
||||
@@ -509,7 +518,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
|
||||
using var lzmaArchive = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.lzma.WinzipAES.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
foreach (var entry in lzmaArchive.Entries.Where(x => !x.IsDirectory))
|
||||
{
|
||||
@@ -523,7 +535,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
{
|
||||
using var archive = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.zstd.WinzipAES.mixed.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
|
||||
VerifyMixedZstandardArchive(archive);
|
||||
@@ -535,7 +550,13 @@ public class ZipArchiveTests : ArchiveTests
|
||||
using var stream = File.OpenRead(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.zstd.WinzipAES.mixed.zip")
|
||||
);
|
||||
using var archive = ZipArchive.OpenArchive(stream, new ReaderOptions { Password = "test" });
|
||||
using var archive = ZipArchive.OpenArchive(
|
||||
stream,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
|
||||
VerifyMixedZstandardArchive(archive);
|
||||
}
|
||||
@@ -571,7 +592,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
// Test that Pkware encrypted entries correctly report their compression type
|
||||
using var deflateArchive = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.pkware.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
foreach (var entry in deflateArchive.Entries.Where(x => !x.IsDirectory))
|
||||
{
|
||||
@@ -581,7 +605,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
|
||||
using var bzip2Archive = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.bzip2.pkware.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
foreach (var entry in bzip2Archive.Entries.Where(x => !x.IsDirectory))
|
||||
{
|
||||
@@ -595,7 +622,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
{
|
||||
using var reader = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.zip64.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
var isComplete = reader.IsComplete;
|
||||
Assert.Equal(1, reader.Volumes.Count());
|
||||
@@ -611,7 +641,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
using (
|
||||
var reader = ZipArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.bzip2.pkware.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -673,7 +706,10 @@ public class ZipArchiveTests : ArchiveTests
|
||||
using var fileStream = File.OpenRead(zipFile);
|
||||
using var archive = ArchiveFactory.OpenArchive(
|
||||
fileStream,
|
||||
new ReaderOptions { Password = "12345678" }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "12345678",
|
||||
}
|
||||
);
|
||||
var entries = archive.Entries.Where(entry => !entry.IsDirectory);
|
||||
foreach (var entry in entries)
|
||||
@@ -881,7 +917,7 @@ public class ZipArchiveTests : ArchiveTests
|
||||
{
|
||||
var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
ArchiveEncoding = new ArchiveEncoding
|
||||
{
|
||||
@@ -896,7 +932,7 @@ public class ZipArchiveTests : ArchiveTests
|
||||
{
|
||||
var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
ArchiveEncoding = new ArchiveEncoding
|
||||
{
|
||||
|
||||
@@ -143,7 +143,10 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
using (
|
||||
IReader baseReader = ZipReader.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -169,7 +172,7 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
await using (
|
||||
var reader = await ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(stream),
|
||||
new ReaderOptions().WithLeaveStreamOpen(false)
|
||||
ReaderOptions.ForExternalStream.WithLeaveStreamOpen(false)
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -215,7 +218,10 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
using (
|
||||
IReader baseReader = ZipReader.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -244,7 +250,10 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
await using (
|
||||
var reader = await ReaderFactory.OpenAsyncReader(
|
||||
stream,
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -272,7 +281,10 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
await using (
|
||||
var reader = await ReaderFactory.OpenAsyncReader(
|
||||
stream,
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
@@ -129,7 +129,15 @@ public class ZipReaderTests : ReaderTests
|
||||
using (
|
||||
Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Zip.bzip2.pkware.zip"))
|
||||
)
|
||||
using (var reader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" }))
|
||||
using (
|
||||
var reader = ZipReader.OpenReader(
|
||||
stream,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
@@ -152,7 +160,7 @@ public class ZipReaderTests : ReaderTests
|
||||
using (
|
||||
var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions().WithLeaveStreamOpen(false)
|
||||
ReaderOptions.ForExternalStream.WithLeaveStreamOpen(false)
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -194,7 +202,13 @@ public class ZipReaderTests : ReaderTests
|
||||
)
|
||||
)
|
||||
using (
|
||||
var reader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" })
|
||||
var reader = ZipReader.OpenReader(
|
||||
stream,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
@@ -217,7 +231,15 @@ public class ZipReaderTests : ReaderTests
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.WinzipAES.zip")
|
||||
)
|
||||
)
|
||||
using (var reader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" }))
|
||||
using (
|
||||
var reader = ZipReader.OpenReader(
|
||||
stream,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
@@ -236,7 +258,15 @@ public class ZipReaderTests : ReaderTests
|
||||
{
|
||||
var count = 0;
|
||||
using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "zipcrypto.zip")))
|
||||
using (var reader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" }))
|
||||
using (
|
||||
var reader = ZipReader.OpenReader(
|
||||
stream,
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
@@ -402,7 +432,10 @@ public class ZipReaderTests : ReaderTests
|
||||
{
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.none.encrypted.zip"),
|
||||
new ReaderOptions { Password = "test" }
|
||||
ReaderOptions.ForFilePath with
|
||||
{
|
||||
Password = "test",
|
||||
}
|
||||
);
|
||||
reader.MoveToNextEntry();
|
||||
Assert.Equal("first.txt", reader.Entry.Key);
|
||||
|
||||
@@ -99,7 +99,10 @@ public class ZipShortReadTests : ReaderTests
|
||||
var names = new List<string>();
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LeaveStreamOpen = true }
|
||||
ReaderOptions.ForExternalStream with
|
||||
{
|
||||
LeaveStreamOpen = true,
|
||||
}
|
||||
);
|
||||
|
||||
while (reader.MoveToNextEntry())
|
||||
|
||||
Reference in New Issue
Block a user