mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
finish the open refactor?
This commit is contained in:
@@ -81,7 +81,10 @@ public static class ArchiveFactory
|
||||
return factory.OpenAsyncArchive(fileInfo, options, cancellationToken);
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(IEnumerable<FileInfo> fileInfos, ReaderOptions? options = null)
|
||||
public static IArchive OpenArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
ReaderOptions? options = null
|
||||
)
|
||||
{
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var filesArray = fileInfos.ToArray();
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace SharpCompress.Factories
|
||||
public IReader OpenReader(Stream stream, ReaderOptions? options) =>
|
||||
AceReader.OpenReader(stream, options);
|
||||
|
||||
public IAsyncReader OpenReaderAsync(
|
||||
public IAsyncReader OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace SharpCompress.Factories
|
||||
public IReader OpenReader(Stream stream, ReaderOptions? options) =>
|
||||
ArcReader.OpenReader(stream, options);
|
||||
|
||||
public IAsyncReader OpenReaderAsync(
|
||||
public IAsyncReader OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace SharpCompress.Factories
|
||||
public IReader OpenReader(Stream stream, ReaderOptions? options) =>
|
||||
ArjReader.OpenReader(stream, options);
|
||||
|
||||
public IAsyncReader OpenReaderAsync(
|
||||
public IAsyncReader OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -133,7 +133,7 @@ public abstract class Factory : IFactory
|
||||
)
|
||||
{
|
||||
((IStreamStack)stream).StackSeek(pos);
|
||||
return (true, readerFactory.OpenReaderAsync(stream, options, cancellationToken));
|
||||
return (true, readerFactory.OpenAsyncReader(stream, options, cancellationToken));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ public class GZipFactory
|
||||
GZipReader.OpenReader(stream, options);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IAsyncReader OpenReaderAsync(
|
||||
public IAsyncReader OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -116,7 +116,7 @@ public class RarFactory : Factory, IArchiveFactory, IMultiArchiveFactory, IReade
|
||||
RarReader.OpenReader(stream, options);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IAsyncReader OpenReaderAsync(
|
||||
public IAsyncReader OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -279,7 +279,7 @@ public class TarFactory
|
||||
TarReader.OpenReader(stream, options);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IAsyncReader OpenReaderAsync(
|
||||
public IAsyncReader OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -203,7 +203,7 @@ public class ZipFactory
|
||||
ZipReader.OpenReader(stream, options);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IAsyncReader OpenReaderAsync(
|
||||
public IAsyncReader OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -49,7 +49,5 @@ public partial class AceReader : IReaderOpenable
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,13 +6,21 @@ namespace SharpCompress.Readers;
|
||||
public interface IReaderFactory : Factories.IFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Opens a Reader for Non-seeking usage
|
||||
/// Opens a Reader for Non-seeking usage.
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
IReader OpenReader(Stream stream, ReaderOptions? options);
|
||||
IAsyncReader OpenReaderAsync(
|
||||
|
||||
/// <summary>
|
||||
/// Opens a Reader for Non-seeking usage asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
IAsyncReader OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken
|
||||
|
||||
@@ -8,7 +8,10 @@ public interface IReaderOpenable
|
||||
{
|
||||
public static abstract IReader OpenReader(string filePath, ReaderOptions? readerOptions = null);
|
||||
|
||||
public static abstract IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null);
|
||||
public static abstract IReader OpenReader(
|
||||
FileInfo fileInfo,
|
||||
ReaderOptions? readerOptions = null
|
||||
);
|
||||
|
||||
public static abstract IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null);
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ public static class ReaderFactory
|
||||
if (testedFactory.IsArchive(bStream))
|
||||
{
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
return readerFactory.OpenReaderAsync(bStream, options, cancellationToken);
|
||||
return readerFactory.OpenAsyncReader(bStream, options, cancellationToken);
|
||||
}
|
||||
}
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
@@ -155,7 +155,7 @@ public static class ReaderFactory
|
||||
if (factory is IReaderFactory readerFactory && factory.IsArchive(bStream))
|
||||
{
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
return readerFactory.OpenReaderAsync(bStream, options, cancellationToken);
|
||||
return readerFactory.OpenAsyncReader(bStream, options, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,11 @@ public partial class ZipReader : AbstractReader<ZipEntry, ZipVolume>
|
||||
return new ZipReader(stream, options ?? new ReaderOptions());
|
||||
}
|
||||
|
||||
public static IReader OpenReader(Stream stream, ReaderOptions? options, IEnumerable<ZipEntry> entries)
|
||||
public static IReader OpenReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
IEnumerable<ZipEntry> entries
|
||||
)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
return new ZipReader(stream, options ?? new ReaderOptions(), entries);
|
||||
|
||||
@@ -36,7 +36,12 @@ public static class WriterFactory
|
||||
)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenAsyncWriter(new FileInfo(filePath), archiveType, writerOptions, cancellationToken);
|
||||
return OpenAsyncWriter(
|
||||
new FileInfo(filePath),
|
||||
archiveType,
|
||||
writerOptions,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(
|
||||
@@ -55,7 +60,11 @@ public static class WriterFactory
|
||||
);
|
||||
}
|
||||
|
||||
public static IWriter OpenWriter(Stream stream, ArchiveType archiveType, WriterOptions writerOptions)
|
||||
public static IWriter OpenWriter(
|
||||
Stream stream,
|
||||
ArchiveType archiveType,
|
||||
WriterOptions writerOptions
|
||||
)
|
||||
{
|
||||
var factory = Factories
|
||||
.Factory.Factories.OfType<IWriterFactory>()
|
||||
|
||||
@@ -21,7 +21,9 @@ public class GZipWriterTests : WriterTests
|
||||
FileAccess.Write
|
||||
)
|
||||
)
|
||||
using (var writer = WriterFactory.OpenWriter(stream, ArchiveType.GZip, CompressionType.GZip))
|
||||
using (
|
||||
var writer = WriterFactory.OpenWriter(stream, ArchiveType.GZip, CompressionType.GZip)
|
||||
)
|
||||
{
|
||||
writer.Write("Tar.tar", Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar"));
|
||||
}
|
||||
@@ -56,7 +58,11 @@ public class GZipWriterTests : WriterTests
|
||||
Assert.Throws<InvalidFormatException>(() =>
|
||||
{
|
||||
using Stream stream = File.OpenWrite(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz"));
|
||||
using var writer = WriterFactory.OpenWriter(stream, ArchiveType.GZip, CompressionType.BZip2);
|
||||
using var writer = WriterFactory.OpenWriter(
|
||||
stream,
|
||||
ArchiveType.GZip,
|
||||
CompressionType.BZip2
|
||||
);
|
||||
});
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -541,7 +541,10 @@ public class ProgressReportTests : TestBase
|
||||
var readerOptions = new ReaderOptions { Progress = progress };
|
||||
|
||||
await using (
|
||||
var reader = ReaderFactory.OpenAsyncReader(new AsyncOnlyStream(archiveStream), readerOptions)
|
||||
var reader = ReaderFactory.OpenAsyncReader(
|
||||
new AsyncOnlyStream(archiveStream),
|
||||
readerOptions
|
||||
)
|
||||
)
|
||||
{
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
|
||||
@@ -151,7 +151,9 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
public async ValueTask Rar_Jpg_ArchiveStreamRead_Async()
|
||||
{
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg"));
|
||||
using (var archive = RarArchive.OpenArchive(stream, new ReaderOptions { LookForHeader = true }))
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(stream, new ReaderOptions { LookForHeader = true })
|
||||
)
|
||||
{
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
{
|
||||
@@ -588,7 +590,9 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
|
||||
private void DoRar_IsFirstVolume_False(string notFirstFilename)
|
||||
{
|
||||
using var archive = RarArchive.OpenArchive(Path.Combine(TEST_ARCHIVES_PATH, notFirstFilename));
|
||||
using var archive = RarArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, notFirstFilename)
|
||||
);
|
||||
Assert.True(archive.IsMultipartVolume());
|
||||
Assert.False(archive.IsFirstVolume());
|
||||
}
|
||||
@@ -697,7 +701,10 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
)
|
||||
{
|
||||
var paths = testArchives.Select(x => Path.Combine(TEST_ARCHIVES_PATH, x));
|
||||
using var archive = ArchiveFactory.OpenArchive(paths.Select(a => new FileInfo(a)), readerOptions);
|
||||
using var archive = ArchiveFactory.OpenArchive(
|
||||
paths.Select(a => new FileInfo(a)),
|
||||
readerOptions
|
||||
);
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
{
|
||||
await entry.WriteToDirectoryAsync(
|
||||
@@ -714,7 +721,10 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
)
|
||||
{
|
||||
var paths = testArchives.Select(x => Path.Combine(TEST_ARCHIVES_PATH, x));
|
||||
using var archive = ArchiveFactory.OpenArchive(paths.Select(f => new FileInfo(f)), readerOptions);
|
||||
using var archive = ArchiveFactory.OpenArchive(
|
||||
paths.Select(f => new FileInfo(f)),
|
||||
readerOptions
|
||||
);
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
{
|
||||
await entry.WriteToDirectoryAsync(
|
||||
|
||||
@@ -148,7 +148,9 @@ public class RarArchiveTests : ArchiveTests
|
||||
public void Rar_Jpg_ArchiveStreamRead()
|
||||
{
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg"));
|
||||
using (var archive = RarArchive.OpenArchive(stream, new ReaderOptions { LookForHeader = true }))
|
||||
using (
|
||||
var archive = RarArchive.OpenArchive(stream, new ReaderOptions { LookForHeader = true })
|
||||
)
|
||||
{
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
{
|
||||
@@ -598,7 +600,9 @@ public class RarArchiveTests : ArchiveTests
|
||||
|
||||
private void DoRar_IsFirstVolume_False(string notFirstFilename)
|
||||
{
|
||||
using var archive = RarArchive.OpenArchive(Path.Combine(TEST_ARCHIVES_PATH, notFirstFilename));
|
||||
using var archive = RarArchive.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, notFirstFilename)
|
||||
);
|
||||
Assert.True(archive.IsMultipartVolume());
|
||||
Assert.False(archive.IsFirstVolume());
|
||||
}
|
||||
|
||||
@@ -279,7 +279,10 @@ public class RarReaderAsyncTests : ReaderTests
|
||||
{
|
||||
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg")))
|
||||
using (
|
||||
IReader baseReader = RarReader.OpenReader(stream, new ReaderOptions { LookForHeader = true })
|
||||
IReader baseReader = RarReader.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
)
|
||||
)
|
||||
{
|
||||
IAsyncReader reader = (IAsyncReader)baseReader;
|
||||
|
||||
@@ -226,7 +226,12 @@ public class RarReaderTests : ReaderTests
|
||||
using (
|
||||
var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.Audio_program.rar"))
|
||||
)
|
||||
using (var reader = ReaderFactory.OpenReader(stream, new ReaderOptions { LookForHeader = true }))
|
||||
using (
|
||||
var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
)
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
@@ -247,7 +252,9 @@ public class RarReaderTests : ReaderTests
|
||||
public void Rar_Jpg_Reader()
|
||||
{
|
||||
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.jpeg.jpg")))
|
||||
using (var reader = RarReader.OpenReader(stream, new ReaderOptions { LookForHeader = true }))
|
||||
using (
|
||||
var reader = RarReader.OpenReader(stream, new ReaderOptions { LookForHeader = true })
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
@@ -282,7 +289,10 @@ public class RarReaderTests : ReaderTests
|
||||
private void DoRar_Solid_Skip_Reader(string filename)
|
||||
{
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, filename));
|
||||
using var reader = ReaderFactory.OpenReader(stream, new ReaderOptions { LookForHeader = true });
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
);
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
if (reader.Entry.Key.NotNull().Contains("jpg"))
|
||||
@@ -305,7 +315,10 @@ public class RarReaderTests : ReaderTests
|
||||
private void DoRar_Reader_Skip(string filename)
|
||||
{
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, filename));
|
||||
using var reader = ReaderFactory.OpenReader(stream, new ReaderOptions { LookForHeader = true });
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
);
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
if (reader.Entry.Key.NotNull().Contains("jpg"))
|
||||
@@ -325,7 +338,10 @@ public class RarReaderTests : ReaderTests
|
||||
using var stream = File.OpenRead(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Rar.encrypted_filesOnly.rar")
|
||||
);
|
||||
using var reader = ReaderFactory.OpenReader(stream, new ReaderOptions { LookForHeader = true });
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
);
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
//
|
||||
|
||||
@@ -190,7 +190,10 @@ public abstract class ReaderTests : TestBase
|
||||
protected void ReadForBufferBoundaryCheck(string fileName, CompressionType compressionType)
|
||||
{
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, fileName));
|
||||
using var reader = ReaderFactory.OpenReader(stream, new ReaderOptions { LookForHeader = true });
|
||||
using var reader = ReaderFactory.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { LookForHeader = true }
|
||||
);
|
||||
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
|
||||
@@ -33,7 +33,13 @@ public class TarArchiveAsyncTests : ArchiveTests
|
||||
|
||||
// Step 1: create a tar file containing a file with the test name
|
||||
using (Stream stream = File.OpenWrite(Path.Combine(SCRATCH2_FILES_PATH, archive)))
|
||||
using (var writer = WriterFactory.OpenAsyncWriter(stream, ArchiveType.Tar, CompressionType.None))
|
||||
using (
|
||||
var writer = WriterFactory.OpenAsyncWriter(
|
||||
stream,
|
||||
ArchiveType.Tar,
|
||||
CompressionType.None
|
||||
)
|
||||
)
|
||||
using (Stream inputStream = new MemoryStream())
|
||||
{
|
||||
var sw = new StreamWriter(inputStream);
|
||||
@@ -47,7 +53,9 @@ public class TarArchiveAsyncTests : ArchiveTests
|
||||
// Step 2: check if the written tar file can be read correctly
|
||||
var unmodified = Path.Combine(SCRATCH2_FILES_PATH, archive);
|
||||
await using (
|
||||
var archive2 = TarArchive.OpenAsyncArchive(new AsyncOnlyStream(File.OpenRead(unmodified)))
|
||||
var archive2 = TarArchive.OpenAsyncArchive(
|
||||
new AsyncOnlyStream(File.OpenRead(unmodified))
|
||||
)
|
||||
)
|
||||
{
|
||||
Assert.Equal(1, await archive2.EntriesAsync.CountAsync());
|
||||
@@ -82,7 +90,13 @@ public class TarArchiveAsyncTests : ArchiveTests
|
||||
|
||||
// Step 1: create a tar file containing a file with a long name
|
||||
using (Stream stream = File.OpenWrite(Path.Combine(SCRATCH2_FILES_PATH, archive)))
|
||||
using (var writer = WriterFactory.OpenAsyncWriter(stream, ArchiveType.Tar, CompressionType.None))
|
||||
using (
|
||||
var writer = WriterFactory.OpenAsyncWriter(
|
||||
stream,
|
||||
ArchiveType.Tar,
|
||||
CompressionType.None
|
||||
)
|
||||
)
|
||||
using (Stream inputStream = new MemoryStream())
|
||||
{
|
||||
var sw = new StreamWriter(inputStream);
|
||||
@@ -96,7 +110,9 @@ public class TarArchiveAsyncTests : ArchiveTests
|
||||
// Step 2: check if the written tar file can be read correctly
|
||||
var unmodified = Path.Combine(SCRATCH2_FILES_PATH, archive);
|
||||
await using (
|
||||
var archive2 = TarArchive.OpenAsyncArchive(new AsyncOnlyStream(File.OpenRead(unmodified)))
|
||||
var archive2 = TarArchive.OpenAsyncArchive(
|
||||
new AsyncOnlyStream(File.OpenRead(unmodified))
|
||||
)
|
||||
)
|
||||
{
|
||||
Assert.Equal(1, await archive2.EntriesAsync.CountAsync());
|
||||
@@ -216,7 +232,9 @@ public class TarArchiveAsyncTests : ArchiveTests
|
||||
|
||||
var numberOfEntries = 0;
|
||||
|
||||
await using (var archiveFactory = TarArchive.OpenAsyncArchive(new AsyncOnlyStream(memoryStream)))
|
||||
await using (
|
||||
var archiveFactory = TarArchive.OpenAsyncArchive(new AsyncOnlyStream(memoryStream))
|
||||
)
|
||||
{
|
||||
await foreach (var entry in archiveFactory.EntriesAsync)
|
||||
{
|
||||
|
||||
@@ -618,7 +618,13 @@ public class ZipArchiveTests : ArchiveTests
|
||||
{
|
||||
MemoryStream stream = new NonSeekableMemoryStream();
|
||||
|
||||
using (var zipWriter = WriterFactory.OpenWriter(stream, ArchiveType.Zip, CompressionType.Deflate))
|
||||
using (
|
||||
var zipWriter = WriterFactory.OpenWriter(
|
||||
stream,
|
||||
ArchiveType.Zip,
|
||||
CompressionType.Deflate
|
||||
)
|
||||
)
|
||||
{
|
||||
zipWriter.Write("foo.txt", new MemoryStream(Array.Empty<byte>()));
|
||||
zipWriter.Write("foo2.txt", new MemoryStream(new byte[10]));
|
||||
@@ -834,7 +840,9 @@ public class ZipArchiveTests : ArchiveTests
|
||||
[Fact]
|
||||
public void Zip_FilePermissions()
|
||||
{
|
||||
using var archive = ArchiveFactory.OpenArchive(Path.Combine(TEST_ARCHIVES_PATH, "Zip.644.zip"));
|
||||
using var archive = ArchiveFactory.OpenArchive(
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.644.zip")
|
||||
);
|
||||
|
||||
var firstEntry = archive.Entries.First();
|
||||
const int S_IFREG = 0x8000;
|
||||
|
||||
@@ -131,7 +131,9 @@ public class ZipTypesLevelsWithCrcRatioAsyncTests : ArchiveTests
|
||||
CompressionLevel = compressionLevel,
|
||||
};
|
||||
|
||||
using (var writer = WriterFactory.OpenAsyncWriter(zipStream, ArchiveType.Zip, writerOptions))
|
||||
using (
|
||||
var writer = WriterFactory.OpenAsyncWriter(zipStream, ArchiveType.Zip, writerOptions)
|
||||
)
|
||||
{
|
||||
await writer.WriteAsync(
|
||||
$"{compressionType}_level_{compressionLevel}_{sizeMb}MiB.txt",
|
||||
|
||||
@@ -121,7 +121,12 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
using (
|
||||
Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Zip.bzip2.pkware.zip"))
|
||||
)
|
||||
using (IReader baseReader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" }))
|
||||
using (
|
||||
IReader baseReader = ZipReader.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { Password = "test" }
|
||||
)
|
||||
)
|
||||
{
|
||||
IAsyncReader reader = (IAsyncReader)baseReader;
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
@@ -193,7 +198,10 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
)
|
||||
)
|
||||
using (
|
||||
IReader baseReader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" })
|
||||
IReader baseReader = ZipReader.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { Password = "test" }
|
||||
)
|
||||
)
|
||||
{
|
||||
IAsyncReader reader = (IAsyncReader)baseReader;
|
||||
@@ -220,7 +228,12 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.WinzipAES.zip"))
|
||||
)
|
||||
)
|
||||
using (IReader baseReader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" }))
|
||||
using (
|
||||
IReader baseReader = ZipReader.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { Password = "test" }
|
||||
)
|
||||
)
|
||||
{
|
||||
IAsyncReader reader = (IAsyncReader)baseReader;
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
@@ -247,7 +260,12 @@ public class ZipReaderAsyncTests : ReaderTests
|
||||
File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "zipcrypto.zip"))
|
||||
)
|
||||
)
|
||||
using (IReader baseReader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" }))
|
||||
using (
|
||||
IReader baseReader = ZipReader.OpenReader(
|
||||
stream,
|
||||
new ReaderOptions { Password = "test" }
|
||||
)
|
||||
)
|
||||
{
|
||||
IAsyncReader reader = (IAsyncReader)baseReader;
|
||||
while (await reader.MoveToNextEntryAsync())
|
||||
|
||||
@@ -179,7 +179,9 @@ public class ZipReaderTests : ReaderTests
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Zip.lzma.WinzipAES.zip")
|
||||
)
|
||||
)
|
||||
using (var reader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" }))
|
||||
using (
|
||||
var reader = ZipReader.OpenReader(stream, new ReaderOptions { Password = "test" })
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
@@ -256,7 +258,13 @@ public class ZipReaderTests : ReaderTests
|
||||
using var memory = new MemoryStream();
|
||||
Stream stream = new TestStream(memory, read: true, write: true, seek: false);
|
||||
|
||||
using (var zipWriter = WriterFactory.OpenWriter(stream, ArchiveType.Zip, CompressionType.Deflate))
|
||||
using (
|
||||
var zipWriter = WriterFactory.OpenWriter(
|
||||
stream,
|
||||
ArchiveType.Zip,
|
||||
CompressionType.Deflate
|
||||
)
|
||||
)
|
||||
{
|
||||
zipWriter.Write(expected[0].Item1, new MemoryStream(expected[0].Item2));
|
||||
zipWriter.Write(expected[1].Item1, new MemoryStream(expected[1].Item2));
|
||||
|
||||
Reference in New Issue
Block a user