mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-04-05 21:51:09 +00:00
first commit for conslidating publci api
This commit is contained in:
@@ -53,20 +53,20 @@ public static partial class ArchiveFactory
|
||||
}
|
||||
|
||||
public static async ValueTask<IAsyncArchive> OpenAsyncArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
IReadOnlyList<FileInfo> fileInfos,
|
||||
ReaderOptions? options = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var filesArray = fileInfos.ToArray();
|
||||
if (filesArray.Length == 0)
|
||||
var filesArray = fileInfos;
|
||||
if (filesArray.Count == 0)
|
||||
{
|
||||
throw new ArchiveOperationException("No files to open");
|
||||
}
|
||||
|
||||
var fileInfo = filesArray[0];
|
||||
if (filesArray.Length == 1)
|
||||
if (filesArray.Count == 1)
|
||||
{
|
||||
return await OpenAsyncArchive(fileInfo, options, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
@@ -83,21 +83,21 @@ public static partial class ArchiveFactory
|
||||
}
|
||||
|
||||
public static async ValueTask<IAsyncArchive> OpenAsyncArchive(
|
||||
IEnumerable<Stream> streams,
|
||||
IReadOnlyList<Stream> streams,
|
||||
ReaderOptions? options = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
streams.NotNull(nameof(streams));
|
||||
var streamsArray = streams.ToArray();
|
||||
if (streamsArray.Length == 0)
|
||||
var streamsArray = streams;
|
||||
if (streamsArray.Count == 0)
|
||||
{
|
||||
throw new ArchiveOperationException("No streams");
|
||||
}
|
||||
|
||||
var firstStream = streamsArray[0];
|
||||
if (streamsArray.Length == 1)
|
||||
if (streamsArray.Count == 1)
|
||||
{
|
||||
return await OpenAsyncArchive(firstStream, options, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
@@ -114,18 +114,18 @@ public static partial class ArchiveFactory
|
||||
}
|
||||
|
||||
public static ValueTask<T> FindFactoryAsync<T>(
|
||||
string path,
|
||||
string filePath,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
where T : IFactory
|
||||
{
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return FindFactoryAsync<T>(new FileInfo(path), cancellationToken);
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return FindFactoryAsync<T>(new FileInfo(filePath), cancellationToken);
|
||||
}
|
||||
|
||||
private static async ValueTask<T> FindFactoryAsync<T>(
|
||||
public static async ValueTask<T> FindFactoryAsync<T>(
|
||||
FileInfo finfo,
|
||||
CancellationToken cancellationToken
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
where T : IFactory
|
||||
{
|
||||
@@ -134,9 +134,9 @@ public static partial class ArchiveFactory
|
||||
return await FindFactoryAsync<T>(stream, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static async ValueTask<T> FindFactoryAsync<T>(
|
||||
public static async ValueTask<T> FindFactoryAsync<T>(
|
||||
Stream stream,
|
||||
CancellationToken cancellationToken
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
where T : IFactory
|
||||
{
|
||||
|
||||
@@ -2,6 +2,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Common.Options;
|
||||
using SharpCompress.Factories;
|
||||
@@ -21,7 +23,7 @@ public static partial class ArchiveFactory
|
||||
where TOptions : IWriterOptions
|
||||
{
|
||||
var factory = Factory
|
||||
.Factories.OfType<IWriteableArchiveFactory<TOptions>>()
|
||||
.Factories.OfType<IWritableArchiveFactory<TOptions>>()
|
||||
.FirstOrDefault();
|
||||
|
||||
if (factory != null)
|
||||
@@ -32,6 +34,24 @@ public static partial class ArchiveFactory
|
||||
throw new NotSupportedException("Cannot create Archives of type: " + typeof(TOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IWritableAsyncArchive<TOptions>> CreateAsyncArchive<TOptions>(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
where TOptions : IWriterOptions
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
var factory = Factory
|
||||
.Factories.OfType<IWritableAsyncArchiveFactory<TOptions>>()
|
||||
.FirstOrDefault();
|
||||
|
||||
if (factory is not null)
|
||||
{
|
||||
return factory.CreateAsyncArchive(cancellationToken);
|
||||
}
|
||||
|
||||
throw new NotSupportedException("Cannot create Archives of type: " + typeof(TOptions));
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(string filePath, ReaderOptions? options = null)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
@@ -46,19 +66,19 @@ public static partial class ArchiveFactory
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
IReadOnlyList<FileInfo> fileInfos,
|
||||
ReaderOptions? options = null
|
||||
)
|
||||
{
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var filesArray = fileInfos.ToArray();
|
||||
if (filesArray.Length == 0)
|
||||
var filesArray = fileInfos;
|
||||
if (filesArray.Count == 0)
|
||||
{
|
||||
throw new ArchiveOperationException("No files to open");
|
||||
}
|
||||
|
||||
var fileInfo = filesArray[0];
|
||||
if (filesArray.Length == 1)
|
||||
if (filesArray.Count == 1)
|
||||
{
|
||||
return OpenArchive(fileInfo, options);
|
||||
}
|
||||
@@ -69,17 +89,17 @@ public static partial class ArchiveFactory
|
||||
return FindFactory<IMultiArchiveFactory>(fileInfo).OpenArchive(filesArray, options);
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(IEnumerable<Stream> streams, ReaderOptions? options = null)
|
||||
public static IArchive OpenArchive(IReadOnlyList<Stream> streams, ReaderOptions? options = null)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
var streamsArray = streams.ToArray();
|
||||
if (streamsArray.Length == 0)
|
||||
var streamsArray = streams;
|
||||
if (streamsArray.Count == 0)
|
||||
{
|
||||
throw new ArchiveOperationException("No streams");
|
||||
}
|
||||
|
||||
var firstStream = streamsArray[0];
|
||||
if (streamsArray.Length == 1)
|
||||
if (streamsArray.Count == 1)
|
||||
{
|
||||
return OpenArchive(firstStream, options);
|
||||
}
|
||||
@@ -100,11 +120,11 @@ public static partial class ArchiveFactory
|
||||
archive.WriteToDirectory(destinationDirectory, options);
|
||||
}
|
||||
|
||||
public static T FindFactory<T>(string path)
|
||||
public static T FindFactory<T>(string filePath)
|
||||
where T : IFactory
|
||||
{
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
using Stream stream = File.OpenRead(path);
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
using Stream stream = File.OpenRead(filePath);
|
||||
return FindFactory<T>(stream);
|
||||
}
|
||||
|
||||
@@ -182,6 +202,46 @@ public static partial class ArchiveFactory
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ValueTask<(bool IsArchive, ArchiveType? Type)> IsArchiveAsync(
|
||||
string filePath,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
using Stream stream = File.OpenRead(filePath);
|
||||
return IsArchiveAsync(stream, cancellationToken);
|
||||
}
|
||||
|
||||
public static async ValueTask<(bool IsArchive, ArchiveType? Type)> IsArchiveAsync(
|
||||
Stream stream,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
stream.NotNull(nameof(stream));
|
||||
|
||||
if (!stream.CanRead || !stream.CanSeek)
|
||||
{
|
||||
throw new ArgumentException("Stream should be readable and seekable");
|
||||
}
|
||||
|
||||
var startPosition = stream.Position;
|
||||
|
||||
foreach (var factory in Factory.Factories)
|
||||
{
|
||||
var isArchive = await factory
|
||||
.IsArchiveAsync(stream, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
stream.Position = startPosition;
|
||||
|
||||
if (isArchive)
|
||||
{
|
||||
return (true, factory.KnownArchiveType);
|
||||
}
|
||||
}
|
||||
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetFileParts(string part1)
|
||||
{
|
||||
part1.NotNullOrEmpty(nameof(part1));
|
||||
|
||||
@@ -21,14 +21,14 @@ public partial class GZipArchive
|
||||
#endif
|
||||
{
|
||||
public static ValueTask<IWritableAsyncArchive<GZipWriterOptions>> OpenAsyncArchive(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return OpenAsyncArchive(new FileInfo(path), readerOptions, cancellationToken);
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenAsyncArchive(new FileInfo(filePath), readerOptions, cancellationToken);
|
||||
}
|
||||
|
||||
public static IWritableArchive<GZipWriterOptions> OpenArchive(
|
||||
@@ -37,7 +37,7 @@ public partial class GZipArchive
|
||||
)
|
||||
{
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenArchive(new FileInfo(filePath), readerOptions ?? new ReaderOptions());
|
||||
return OpenArchive(new FileInfo(filePath), readerOptions ?? ReaderOptions.ForFilePath);
|
||||
}
|
||||
|
||||
public static IWritableArchive<GZipWriterOptions> OpenArchive(
|
||||
@@ -50,39 +50,39 @@ public partial class GZipArchive
|
||||
new SourceStream(
|
||||
fileInfo,
|
||||
i => ArchiveVolumeFactory.GetFilePart(i, fileInfo),
|
||||
readerOptions ?? new ReaderOptions()
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IWritableArchive<GZipWriterOptions> OpenArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
IReadOnlyList<FileInfo> fileInfos,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var files = fileInfos.ToArray();
|
||||
var files = fileInfos;
|
||||
return new GZipArchive(
|
||||
new SourceStream(
|
||||
files[0],
|
||||
i => i < files.Length ? files[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < files.Count ? files[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IWritableArchive<GZipWriterOptions> OpenArchive(
|
||||
IEnumerable<Stream> streams,
|
||||
IReadOnlyList<Stream> streams,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
var strms = streams.ToArray();
|
||||
var strms = streams;
|
||||
return new GZipArchive(
|
||||
new SourceStream(
|
||||
strms[0],
|
||||
i => i < strms.Length ? strms[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < strms.Count ? strms[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForExternalStream
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public partial class GZipArchive
|
||||
}
|
||||
|
||||
return new GZipArchive(
|
||||
new SourceStream(stream, _ => null, readerOptions ?? new ReaderOptions())
|
||||
new SourceStream(stream, _ => null, readerOptions ?? ReaderOptions.ForExternalStream)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public interface IArchiveOpenable<TSync, TASync>
|
||||
public static abstract TSync OpenArchive(Stream stream, ReaderOptions? readerOptions = null);
|
||||
|
||||
public static abstract ValueTask<TASync> OpenAsyncArchive(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
@@ -12,12 +12,12 @@ public interface IMultiArchiveOpenable<TSync, TASync>
|
||||
where TASync : IAsyncArchive
|
||||
{
|
||||
public static abstract TSync OpenArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
IReadOnlyList<FileInfo> fileInfos,
|
||||
ReaderOptions? readerOptions = null
|
||||
);
|
||||
|
||||
public static abstract TSync OpenArchive(
|
||||
IEnumerable<Stream> streams,
|
||||
IReadOnlyList<Stream> streams,
|
||||
ReaderOptions? readerOptions = null
|
||||
);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public static class IWritableArchiveExtensions
|
||||
var path in Directory.EnumerateFiles(filePath, searchPattern, searchOption)
|
||||
)
|
||||
{
|
||||
var fileInfo = new FileInfo(path);
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
writableArchive.AddEntry(
|
||||
path.Substring(filePath.Length),
|
||||
fileInfo.OpenRead(),
|
||||
|
||||
@@ -24,7 +24,7 @@ public static class IWritableAsyncArchiveExtensions
|
||||
var path in Directory.EnumerateFiles(filePath, searchPattern, searchOption)
|
||||
)
|
||||
{
|
||||
var fileInfo = new FileInfo(path);
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
await writableArchive
|
||||
.AddEntryAsync(
|
||||
path.Substring(filePath.Length),
|
||||
|
||||
19
src/SharpCompress/Archives/IWritableAsyncArchiveFactory.cs
Normal file
19
src/SharpCompress/Archives/IWritableAsyncArchiveFactory.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common.Options;
|
||||
|
||||
namespace SharpCompress.Archives;
|
||||
|
||||
/// <summary>
|
||||
/// Decorator for <see cref="Factories.Factory"/> used to declare an archive format as able to create async writable archives.
|
||||
/// </summary>
|
||||
public interface IWritableAsyncArchiveFactory<TOptions> : Factories.IFactory
|
||||
where TOptions : IWriterOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new, empty async archive, ready to be written.
|
||||
/// </summary>
|
||||
ValueTask<IWritableAsyncArchive<TOptions>> CreateAsyncArchive(
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using SharpCompress.Common.Options;
|
||||
namespace SharpCompress.Archives;
|
||||
|
||||
/// <summary>
|
||||
/// Decorator for <see cref="Factories.Factory"/> used to declare an archive format as able to create writeable archives
|
||||
/// Decorator for <see cref="Factories.Factory"/> used to declare an archive format as able to create writable archives.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Implemented by:<br/>
|
||||
@@ -12,7 +12,8 @@ namespace SharpCompress.Archives;
|
||||
/// <item><see cref="Factories.ZipFactory"/></item>
|
||||
/// <item><see cref="Factories.GZipFactory"/></item>
|
||||
/// </list>
|
||||
public interface IWriteableArchiveFactory<TOptions> : Factories.IFactory
|
||||
/// </remarks>
|
||||
public interface IWritableArchiveFactory<TOptions> : Factories.IFactory
|
||||
where TOptions : IWriterOptions
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -21,14 +21,14 @@ public partial class RarArchive
|
||||
#endif
|
||||
{
|
||||
public static ValueTask<IRarAsyncArchive> OpenAsyncArchive(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return new((IRarAsyncArchive)OpenArchive(new FileInfo(path), readerOptions));
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new((IRarAsyncArchive)OpenArchive(new FileInfo(filePath), readerOptions));
|
||||
}
|
||||
|
||||
public static IRarArchive OpenArchive(string filePath, ReaderOptions? readerOptions = null)
|
||||
@@ -39,7 +39,7 @@ public partial class RarArchive
|
||||
new SourceStream(
|
||||
fileInfo,
|
||||
i => RarArchiveVolumeFactory.GetFilePart(i, fileInfo),
|
||||
readerOptions ?? new ReaderOptions()
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -71,33 +71,33 @@ public partial class RarArchive
|
||||
}
|
||||
|
||||
public static IRarArchive OpenArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
IReadOnlyList<FileInfo> fileInfos,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var files = fileInfos.ToArray();
|
||||
var files = fileInfos;
|
||||
return new RarArchive(
|
||||
new SourceStream(
|
||||
files[0],
|
||||
i => i < files.Length ? files[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < files.Count ? files[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IRarArchive OpenArchive(
|
||||
IEnumerable<Stream> streams,
|
||||
IReadOnlyList<Stream> streams,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
var strms = streams.ToArray();
|
||||
var strms = streams;
|
||||
return new RarArchive(
|
||||
new SourceStream(
|
||||
strms[0],
|
||||
i => i < strms.Length ? strms[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < strms.Count ? strms[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForExternalStream
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,22 +17,25 @@ public partial class SevenZipArchive
|
||||
#endif
|
||||
{
|
||||
public static ValueTask<IAsyncArchive> OpenAsyncArchive(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty("path");
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new(
|
||||
(IAsyncArchive)OpenArchive(new FileInfo(path), readerOptions ?? new ReaderOptions())
|
||||
(IAsyncArchive)OpenArchive(
|
||||
new FileInfo(filePath),
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(string filePath, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
filePath.NotNullOrEmpty("filePath");
|
||||
return OpenArchive(new FileInfo(filePath), readerOptions ?? new ReaderOptions());
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenArchive(new FileInfo(filePath), readerOptions ?? ReaderOptions.ForFilePath);
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
@@ -42,39 +45,39 @@ public partial class SevenZipArchive
|
||||
new SourceStream(
|
||||
fileInfo,
|
||||
i => ArchiveVolumeFactory.GetFilePart(i, fileInfo),
|
||||
readerOptions ?? new ReaderOptions()
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
IReadOnlyList<FileInfo> fileInfos,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var files = fileInfos.ToArray();
|
||||
var files = fileInfos;
|
||||
return new SevenZipArchive(
|
||||
new SourceStream(
|
||||
files[0],
|
||||
i => i < files.Length ? files[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < files.Count ? files[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IArchive OpenArchive(
|
||||
IEnumerable<Stream> streams,
|
||||
IReadOnlyList<Stream> streams,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
var strms = streams.ToArray();
|
||||
var strms = streams;
|
||||
return new SevenZipArchive(
|
||||
new SourceStream(
|
||||
strms[0],
|
||||
i => i < strms.Length ? strms[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < strms.Count ? strms[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForExternalStream
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -89,7 +92,7 @@ public partial class SevenZipArchive
|
||||
}
|
||||
|
||||
return new SevenZipArchive(
|
||||
new SourceStream(stream, _ => null, readerOptions ?? new ReaderOptions())
|
||||
new SourceStream(stream, _ => null, readerOptions ?? ReaderOptions.ForExternalStream)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,23 +38,20 @@ public partial class TarArchive
|
||||
)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
return OpenArchive(
|
||||
[fileInfo],
|
||||
readerOptions ?? new ReaderOptions() { LeaveStreamOpen = false }
|
||||
);
|
||||
return OpenArchive([fileInfo], readerOptions ?? ReaderOptions.ForFilePath);
|
||||
}
|
||||
|
||||
public static IWritableArchive<TarWriterOptions> OpenArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
IReadOnlyList<FileInfo> fileInfos,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var files = fileInfos.ToArray();
|
||||
var files = fileInfos;
|
||||
var sourceStream = new SourceStream(
|
||||
files[0],
|
||||
i => i < files.Length ? files[i] : null,
|
||||
readerOptions ?? new ReaderOptions() { LeaveStreamOpen = false }
|
||||
i => i < files.Count ? files[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
);
|
||||
var compressionType = TarFactory.GetCompressionType(
|
||||
sourceStream,
|
||||
@@ -65,16 +62,16 @@ public partial class TarArchive
|
||||
}
|
||||
|
||||
public static IWritableArchive<TarWriterOptions> OpenArchive(
|
||||
IEnumerable<Stream> streams,
|
||||
IReadOnlyList<Stream> streams,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
var strms = streams.ToArray();
|
||||
var strms = streams;
|
||||
var sourceStream = new SourceStream(
|
||||
strms[0],
|
||||
i => i < strms.Length ? strms[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < strms.Count ? strms[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForExternalStream
|
||||
);
|
||||
var compressionType = TarFactory.GetCompressionType(
|
||||
sourceStream,
|
||||
@@ -109,7 +106,7 @@ public partial class TarArchive
|
||||
var sourceStream = new SourceStream(
|
||||
stream,
|
||||
i => null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
readerOptions ?? ReaderOptions.ForExternalStream
|
||||
);
|
||||
var compressionType = await TarFactory
|
||||
.GetCompressionTypeAsync(
|
||||
@@ -123,14 +120,14 @@ public partial class TarArchive
|
||||
}
|
||||
|
||||
public static ValueTask<IWritableAsyncArchive<TarWriterOptions>> OpenAsyncArchive(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return OpenAsyncArchive(new FileInfo(path), readerOptions, cancellationToken);
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenAsyncArchive(new FileInfo(filePath), readerOptions, cancellationToken);
|
||||
}
|
||||
|
||||
public static async ValueTask<IWritableAsyncArchive<TarWriterOptions>> OpenAsyncArchive(
|
||||
@@ -141,7 +138,7 @@ public partial class TarArchive
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
readerOptions ??= new ReaderOptions() { LeaveStreamOpen = false };
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
var sourceStream = new SourceStream(fileInfo, i => null, readerOptions);
|
||||
var compressionType = await TarFactory
|
||||
.GetCompressionTypeAsync(
|
||||
@@ -162,11 +159,11 @@ public partial class TarArchive
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
streams.NotNull(nameof(streams));
|
||||
var strms = streams.ToArray();
|
||||
var strms = streams;
|
||||
var sourceStream = new SourceStream(
|
||||
strms[0],
|
||||
i => i < strms.Length ? strms[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < strms.Count ? strms[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForExternalStream
|
||||
);
|
||||
var compressionType = await TarFactory
|
||||
.GetCompressionTypeAsync(
|
||||
@@ -187,11 +184,11 @@ public partial class TarArchive
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var files = fileInfos.ToArray();
|
||||
var files = fileInfos;
|
||||
var sourceStream = new SourceStream(
|
||||
files[0],
|
||||
i => i < files.Length ? files[i] : null,
|
||||
readerOptions ?? new ReaderOptions() { LeaveStreamOpen = false }
|
||||
i => i < files.Count ? files[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForFilePath
|
||||
);
|
||||
var compressionType = await TarFactory
|
||||
.GetCompressionTypeAsync(
|
||||
|
||||
@@ -47,33 +47,33 @@ public partial class ZipArchive
|
||||
}
|
||||
|
||||
public static IWritableArchive<ZipWriterOptions> OpenArchive(
|
||||
IEnumerable<FileInfo> fileInfos,
|
||||
IReadOnlyList<FileInfo> fileInfos,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
fileInfos.NotNull(nameof(fileInfos));
|
||||
var files = fileInfos.ToArray();
|
||||
var files = fileInfos;
|
||||
return new ZipArchive(
|
||||
new SourceStream(
|
||||
files[0],
|
||||
i => i < files.Length ? files[i] : null,
|
||||
i => i < files.Count ? files[i] : null,
|
||||
readerOptions ?? new ReaderOptions() { LeaveStreamOpen = false }
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static IWritableArchive<ZipWriterOptions> OpenArchive(
|
||||
IEnumerable<Stream> streams,
|
||||
IReadOnlyList<Stream> streams,
|
||||
ReaderOptions? readerOptions = null
|
||||
)
|
||||
{
|
||||
streams.NotNull(nameof(streams));
|
||||
var strms = streams.ToArray();
|
||||
var strms = streams;
|
||||
return new ZipArchive(
|
||||
new SourceStream(
|
||||
strms[0],
|
||||
i => i < strms.Length ? strms[i] : null,
|
||||
readerOptions ?? new ReaderOptions()
|
||||
i => i < strms.Count ? strms[i] : null,
|
||||
readerOptions ?? ReaderOptions.ForExternalStream
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -91,18 +91,18 @@ public partial class ZipArchive
|
||||
}
|
||||
|
||||
return new ZipArchive(
|
||||
new SourceStream(stream, i => null, readerOptions ?? new ReaderOptions())
|
||||
new SourceStream(stream, i => null, readerOptions ?? ReaderOptions.ForExternalStream)
|
||||
);
|
||||
}
|
||||
|
||||
public static ValueTask<IWritableAsyncArchive<ZipWriterOptions>> OpenAsyncArchive(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IWritableAsyncArchive<ZipWriterOptions>)OpenArchive(path, readerOptions));
|
||||
return new((IWritableAsyncArchive<ZipWriterOptions>)OpenArchive(filePath, readerOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IWritableAsyncArchive<ZipWriterOptions>> OpenAsyncArchive(
|
||||
|
||||
@@ -27,7 +27,8 @@ public class GZipFactory
|
||||
IMultiArchiveFactory,
|
||||
IReaderFactory,
|
||||
IWriterFactory,
|
||||
IWriteableArchiveFactory<GZipWriterOptions>
|
||||
IWritableArchiveFactory<GZipWriterOptions>,
|
||||
IWritableAsyncArchiveFactory<GZipWriterOptions>
|
||||
{
|
||||
#region IFactory
|
||||
|
||||
@@ -218,10 +219,19 @@ public class GZipFactory
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWriteableArchiveFactory
|
||||
#region IWritableArchiveFactory
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IWritableArchive<GZipWriterOptions> CreateArchive() => GZipArchive.CreateArchive();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ValueTask<IWritableAsyncArchive<GZipWriterOptions>> CreateAsyncArchive(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return GZipArchive.CreateAsyncArchive();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ public class TarFactory
|
||||
IMultiArchiveFactory,
|
||||
IReaderFactory,
|
||||
IWriterFactory,
|
||||
IWriteableArchiveFactory<TarWriterOptions>
|
||||
IWritableArchiveFactory<TarWriterOptions>,
|
||||
IWritableAsyncArchiveFactory<TarWriterOptions>
|
||||
{
|
||||
#region IFactory
|
||||
|
||||
@@ -421,10 +422,19 @@ public class TarFactory
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWriteableArchiveFactory
|
||||
#region IWritableArchiveFactory
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IWritableArchive<TarWriterOptions> CreateArchive() => TarArchive.CreateArchive();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ValueTask<IWritableAsyncArchive<TarWriterOptions>> CreateAsyncArchive(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return TarArchive.CreateAsyncArchive();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ public class ZipFactory
|
||||
IMultiArchiveFactory,
|
||||
IReaderFactory,
|
||||
IWriterFactory,
|
||||
IWriteableArchiveFactory<ZipWriterOptions>
|
||||
IWritableArchiveFactory<ZipWriterOptions>,
|
||||
IWritableAsyncArchiveFactory<ZipWriterOptions>
|
||||
{
|
||||
#region IFactory
|
||||
|
||||
@@ -246,10 +247,19 @@ public class ZipFactory
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWriteableArchiveFactory
|
||||
#region IWritableArchiveFactory
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IWritableArchive<ZipWriterOptions> CreateArchive() => ZipArchive.CreateArchive();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ValueTask<IWritableAsyncArchive<ZipWriterOptions>> CreateAsyncArchive(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return ZipArchive.CreateAsyncArchive();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -22,20 +22,16 @@ public abstract partial class AbstractReader<TEntry, TVolume> : IReader, IAsyncR
|
||||
private bool _wroteCurrentEntry;
|
||||
private readonly bool _disposeVolume;
|
||||
|
||||
internal AbstractReader(
|
||||
ReaderOptions options,
|
||||
ArchiveType archiveType,
|
||||
bool disposeVolume = true
|
||||
)
|
||||
internal AbstractReader(ReaderOptions options, ArchiveType type, bool disposeVolume = true)
|
||||
{
|
||||
ArchiveType = archiveType;
|
||||
Type = type;
|
||||
_disposeVolume = disposeVolume;
|
||||
Options = options;
|
||||
}
|
||||
|
||||
internal ReaderOptions Options { get; }
|
||||
|
||||
public ArchiveType ArchiveType { get; }
|
||||
public ArchiveType Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current volume that the current entry resides in
|
||||
|
||||
@@ -36,14 +36,14 @@ public partial class AceReader
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(path), readerOptions));
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(filePath), readerOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
@@ -84,6 +84,7 @@ public partial class AceReader
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace SharpCompress.Readers.Arc;
|
||||
public partial class ArcReader : IReaderOpenable
|
||||
{
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(path), readerOptions));
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(filePath), readerOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
@@ -48,6 +48,7 @@ public partial class ArcReader : IReaderOpenable
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace SharpCompress.Readers.Arj;
|
||||
public partial class ArjReader : IReaderOpenable
|
||||
{
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(path), readerOptions));
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(filePath), readerOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
@@ -48,6 +48,7 @@ public partial class ArjReader : IReaderOpenable
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ public partial class GZipReader
|
||||
#endif
|
||||
{
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(path), readerOptions));
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(filePath), readerOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
@@ -49,6 +49,7 @@ public partial class GZipReader
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SharpCompress.Readers;
|
||||
|
||||
public interface IAsyncReader : IAsyncDisposable
|
||||
{
|
||||
ArchiveType ArchiveType { get; }
|
||||
ArchiveType Type { get; }
|
||||
|
||||
IEntry Entry { get; }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace SharpCompress.Readers;
|
||||
|
||||
public interface IReader : IDisposable
|
||||
{
|
||||
ArchiveType ArchiveType { get; }
|
||||
ArchiveType Type { get; }
|
||||
|
||||
IEntry Entry { get; }
|
||||
|
||||
|
||||
@@ -24,6 +24,6 @@ public interface IReaderFactory : Factories.IFactory
|
||||
ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options,
|
||||
CancellationToken cancellationToken
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface IReaderOpenable
|
||||
public static abstract IReader OpenReader(Stream stream, ReaderOptions? readerOptions = null);
|
||||
|
||||
public static abstract ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
@@ -10,14 +10,14 @@ public partial class LzwReader
|
||||
#endif
|
||||
{
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(path), readerOptions));
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(filePath), readerOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
@@ -49,6 +49,7 @@ public partial class LzwReader
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace SharpCompress.Readers.Rar;
|
||||
public partial class RarReader : IReaderOpenable
|
||||
{
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(path), readerOptions));
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(filePath), readerOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract partial class RarReader : AbstractReader<RarReaderEntry, RarVolu
|
||||
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
readerOptions ??= new ReaderOptions { LeaveStreamOpen = false };
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public abstract partial class RarReader : AbstractReader<RarReaderEntry, RarVolu
|
||||
|
||||
public static IReader OpenReader(IEnumerable<FileInfo> fileInfos, ReaderOptions? options = null)
|
||||
{
|
||||
options ??= new ReaderOptions { LeaveStreamOpen = false };
|
||||
options ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfos.Select(x => x.OpenRead()), options);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,13 +71,13 @@ public partial class TarReader
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return OpenAsyncReader(new FileInfo(path), readerOptions, cancellationToken);
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return OpenAsyncReader(new FileInfo(filePath), readerOptions, cancellationToken);
|
||||
}
|
||||
|
||||
public static async ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
@@ -139,7 +139,7 @@ public partial class TarReader
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
readerOptions ??= new ReaderOptions() { LeaveStreamOpen = false };
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
var stream = fileInfo.OpenAsyncReadStream(cancellationToken);
|
||||
return await OpenAsyncReader(stream, readerOptions, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
@@ -154,7 +154,7 @@ public partial class TarReader
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
readerOptions ??= new ReaderOptions() { LeaveStreamOpen = false };
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace SharpCompress.Readers.Zip;
|
||||
public partial class ZipReader : IReaderOpenable
|
||||
{
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string path,
|
||||
string filePath,
|
||||
ReaderOptions? readerOptions = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
path.NotNullOrEmpty(nameof(path));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(path), readerOptions));
|
||||
filePath.NotNullOrEmpty(nameof(filePath));
|
||||
return new((IAsyncReader)OpenReader(new FileInfo(filePath), readerOptions));
|
||||
}
|
||||
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
@@ -48,6 +48,7 @@ public partial class ZipReader : IReaderOpenable
|
||||
public static IReader OpenReader(FileInfo fileInfo, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
readerOptions ??= ReaderOptions.ForFilePath;
|
||||
return OpenReader(fileInfo.OpenRead(), readerOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public abstract partial class AbstractWriter(ArchiveType type, IWriterOptions wr
|
||||
|
||||
protected Stream? OutputStream { get; private set; }
|
||||
|
||||
public ArchiveType WriterType { get; } = type;
|
||||
public ArchiveType Type { get; } = type;
|
||||
|
||||
protected IWriterOptions WriterOptions { get; } = writerOptions;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#if NET8_0_OR_GREATER
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common;
|
||||
|
||||
namespace SharpCompress.Writers.GZip;
|
||||
@@ -15,7 +17,7 @@ public partial class GZipWriter : IWriterOpenable<GZipWriterOptions>
|
||||
public static IWriter OpenWriter(FileInfo fileInfo, GZipWriterOptions writerOptions)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
return new GZipWriter(fileInfo.OpenWrite(), writerOptions);
|
||||
return new GZipWriter(fileInfo.OpenWrite(), writerOptions with { LeaveStreamOpen = false });
|
||||
}
|
||||
|
||||
public static IWriter OpenWriter(Stream stream, GZipWriterOptions writerOptions)
|
||||
@@ -24,19 +26,34 @@ public partial class GZipWriter : IWriterOpenable<GZipWriterOptions>
|
||||
return new GZipWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(string stream, GZipWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
string filePath,
|
||||
GZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(filePath, writerOptions));
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(Stream stream, GZipWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
Stream stream,
|
||||
GZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(stream, writerOptions));
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(FileInfo fileInfo, GZipWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
FileInfo fileInfo,
|
||||
GZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(fileInfo, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(fileInfo, writerOptions));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,14 +8,14 @@ namespace SharpCompress.Writers;
|
||||
|
||||
public interface IWriter : IDisposable
|
||||
{
|
||||
ArchiveType WriterType { get; }
|
||||
ArchiveType Type { get; }
|
||||
void Write(string filename, Stream source, DateTime? modificationTime);
|
||||
void WriteDirectory(string directoryName, DateTime? modificationTime);
|
||||
}
|
||||
|
||||
public interface IAsyncWriter : IDisposable, IAsyncDisposable
|
||||
{
|
||||
ArchiveType WriterType { get; }
|
||||
ArchiveType Type { get; }
|
||||
ValueTask WriteAsync(
|
||||
string filename,
|
||||
Stream source,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#if NET8_0_OR_GREATER
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common.Options;
|
||||
|
||||
namespace SharpCompress.Writers;
|
||||
@@ -17,22 +18,25 @@ public interface IWriterOpenable<TWriterOptions>
|
||||
/// Opens a Writer asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream to write to.</param>
|
||||
/// <param name="archiveType">The archive type.</param>
|
||||
/// <param name="writerOptions">Writer options.</param>
|
||||
/// <returns>A task that returns an IWriter.</returns>
|
||||
public static abstract IAsyncWriter OpenAsyncWriter(
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>A task that returns an async writer.</returns>
|
||||
public static abstract ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
Stream stream,
|
||||
TWriterOptions writerOptions
|
||||
TWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
public static abstract IAsyncWriter OpenAsyncWriter(
|
||||
public static abstract ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
string filePath,
|
||||
TWriterOptions writerOptions
|
||||
TWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
public static abstract IAsyncWriter OpenAsyncWriter(
|
||||
public static abstract ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
FileInfo fileInfo,
|
||||
TWriterOptions writerOptions
|
||||
TWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#if NET8_0_OR_GREATER
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharpCompress.Writers.SevenZip;
|
||||
|
||||
@@ -20,7 +22,13 @@ public partial class SevenZipWriter : IWriterOpenable<SevenZipWriterOptions>
|
||||
public static IWriter OpenWriter(FileInfo fileInfo, SevenZipWriterOptions writerOptions)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
return new SevenZipWriter(fileInfo.OpenWrite(), writerOptions);
|
||||
return new SevenZipWriter(
|
||||
fileInfo.OpenWrite(),
|
||||
writerOptions with
|
||||
{
|
||||
LeaveStreamOpen = false,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -35,28 +43,40 @@ public partial class SevenZipWriter : IWriterOpenable<SevenZipWriterOptions>
|
||||
/// <summary>
|
||||
/// Opens a new async SevenZipWriter for the specified file path.
|
||||
/// </summary>
|
||||
public static IAsyncWriter OpenAsyncWriter(string filePath, SevenZipWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
string filePath,
|
||||
SevenZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(filePath, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(filePath, writerOptions));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a new async SevenZipWriter for the specified stream.
|
||||
/// </summary>
|
||||
public static IAsyncWriter OpenAsyncWriter(Stream stream, SevenZipWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
Stream stream,
|
||||
SevenZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(stream, writerOptions));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a new async SevenZipWriter for the specified file.
|
||||
/// </summary>
|
||||
public static IAsyncWriter OpenAsyncWriter(
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
FileInfo fileInfo,
|
||||
SevenZipWriterOptions writerOptions
|
||||
SevenZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(fileInfo, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(fileInfo, writerOptions));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#if NET8_0_OR_GREATER
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common;
|
||||
|
||||
namespace SharpCompress.Writers.Tar;
|
||||
@@ -15,7 +17,7 @@ public partial class TarWriter : IWriterOpenable<TarWriterOptions>
|
||||
public static IWriter OpenWriter(FileInfo fileInfo, TarWriterOptions writerOptions)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
return new TarWriter(fileInfo.OpenWrite(), writerOptions);
|
||||
return new TarWriter(fileInfo.OpenWrite(), writerOptions with { LeaveStreamOpen = false });
|
||||
}
|
||||
|
||||
public static IWriter OpenWriter(Stream stream, TarWriterOptions writerOptions)
|
||||
@@ -24,19 +26,34 @@ public partial class TarWriter : IWriterOpenable<TarWriterOptions>
|
||||
return new TarWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(string stream, TarWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
string filePath,
|
||||
TarWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(filePath, writerOptions));
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(Stream stream, TarWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
Stream stream,
|
||||
TarWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(stream, writerOptions));
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(FileInfo fileInfo, TarWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
FileInfo fileInfo,
|
||||
TarWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(fileInfo, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(fileInfo, writerOptions));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#if NET8_0_OR_GREATER
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common;
|
||||
|
||||
namespace SharpCompress.Writers.Zip;
|
||||
@@ -15,7 +17,7 @@ public partial class ZipWriter : IWriterOpenable<ZipWriterOptions>
|
||||
public static IWriter OpenWriter(FileInfo fileInfo, ZipWriterOptions writerOptions)
|
||||
{
|
||||
fileInfo.NotNull(nameof(fileInfo));
|
||||
return new ZipWriter(fileInfo.OpenWrite(), writerOptions);
|
||||
return new ZipWriter(fileInfo.OpenWrite(), writerOptions with { LeaveStreamOpen = false });
|
||||
}
|
||||
|
||||
public static IWriter OpenWriter(Stream stream, ZipWriterOptions writerOptions)
|
||||
@@ -24,19 +26,34 @@ public partial class ZipWriter : IWriterOpenable<ZipWriterOptions>
|
||||
return new ZipWriter(stream, writerOptions);
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(string stream, ZipWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
string filePath,
|
||||
ZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(filePath, writerOptions));
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(Stream stream, ZipWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
Stream stream,
|
||||
ZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(stream, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(stream, writerOptions));
|
||||
}
|
||||
|
||||
public static IAsyncWriter OpenAsyncWriter(FileInfo fileInfo, ZipWriterOptions writerOptions)
|
||||
public static ValueTask<IAsyncWriter> OpenAsyncWriter(
|
||||
FileInfo fileInfo,
|
||||
ZipWriterOptions writerOptions,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
return (IAsyncWriter)OpenWriter(fileInfo, writerOptions);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new((IAsyncWriter)OpenWriter(fileInfo, writerOptions));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -179,7 +179,7 @@ public class ArchiveTests : ReaderTests
|
||||
{
|
||||
using (
|
||||
var archive = ArchiveFactory.OpenArchive(
|
||||
testArchives.Select(a => new FileInfo(a)),
|
||||
testArchives.Select(a => new FileInfo(a)).ToArray(),
|
||||
readerOptions
|
||||
)
|
||||
)
|
||||
@@ -208,7 +208,7 @@ public class ArchiveTests : ReaderTests
|
||||
{
|
||||
using (
|
||||
var archive = ArchiveFactory.OpenArchive(
|
||||
testArchives.Select(f => new FileInfo(f)),
|
||||
testArchives.Select(f => new FileInfo(f)).ToArray(),
|
||||
readerOptions
|
||||
)
|
||||
)
|
||||
@@ -240,7 +240,7 @@ public class ArchiveTests : ReaderTests
|
||||
{
|
||||
var src = testArchives.ToArray();
|
||||
using var archive = ArchiveFactory.OpenArchive(
|
||||
src.Select(f => new FileInfo(f)),
|
||||
src.Select(f => new FileInfo(f)).ToArray(),
|
||||
readerOptions
|
||||
);
|
||||
var idx = 0;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class LzwReaderAsyncTests : ReaderTests
|
||||
using Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "large_test.txt.Z"));
|
||||
using var reader = LzwReader.OpenReader(stream);
|
||||
|
||||
Assert.Equal(ArchiveType.Lzw, reader.ArchiveType);
|
||||
Assert.Equal(ArchiveType.Lzw, reader.Type);
|
||||
Assert.True(reader.MoveToNextEntry());
|
||||
|
||||
var entry = reader.Entry;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class LzwReaderTests : ReaderTests
|
||||
);
|
||||
|
||||
// Should detect as Tar archive with Lzw compression
|
||||
Assert.Equal(ArchiveType.Tar, reader.ArchiveType);
|
||||
Assert.Equal(ArchiveType.Tar, reader.Type);
|
||||
Assert.True(reader.MoveToNextEntry());
|
||||
Assert.NotNull(reader.Entry);
|
||||
Assert.Equal(CompressionType.Lzw, reader.Entry.CompressionType);
|
||||
@@ -80,7 +80,7 @@ public class LzwReaderTests : ReaderTests
|
||||
using var reader = ReaderFactory.OpenReader(stream);
|
||||
|
||||
// Should detect as Lzw archive (not Tar)
|
||||
Assert.Equal(ArchiveType.Lzw, reader.ArchiveType);
|
||||
Assert.Equal(ArchiveType.Lzw, reader.Type);
|
||||
Assert.True(reader.MoveToNextEntry());
|
||||
Assert.NotNull(reader.Entry);
|
||||
Assert.Equal(CompressionType.Lzw, reader.Entry.CompressionType);
|
||||
|
||||
@@ -253,7 +253,10 @@ public class RarArchiveAsyncTests : ArchiveTests
|
||||
private async ValueTask DoRar_Multi_ArchiveStreamReadAsync(string[] archives, bool isSolid)
|
||||
{
|
||||
using var archive = RarArchive.OpenArchive(
|
||||
archives.Select(s => Path.Combine(TEST_ARCHIVES_PATH, s)).Select(File.OpenRead)
|
||||
archives
|
||||
.Select(s => Path.Combine(TEST_ARCHIVES_PATH, s))
|
||||
.Select(File.OpenRead)
|
||||
.ToArray()
|
||||
);
|
||||
Assert.Equal(archive.IsSolid, isSolid);
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
@@ -672,7 +675,7 @@ 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)),
|
||||
paths.Select(a => new FileInfo(a)).ToArray(),
|
||||
readerOptions
|
||||
);
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
@@ -730,7 +733,7 @@ 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)),
|
||||
paths.Select(f => new FileInfo(f)).ToArray(),
|
||||
readerOptions
|
||||
);
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
|
||||
@@ -242,7 +242,10 @@ public class RarArchiveTests : ArchiveTests
|
||||
private void DoRar_Multi_ArchiveStreamRead(string[] archives, bool isSolid)
|
||||
{
|
||||
using var archive = RarArchive.OpenArchive(
|
||||
archives.Select(s => Path.Combine(TEST_ARCHIVES_PATH, s)).Select(File.OpenRead)
|
||||
archives
|
||||
.Select(s => Path.Combine(TEST_ARCHIVES_PATH, s))
|
||||
.Select(File.OpenRead)
|
||||
.ToArray()
|
||||
);
|
||||
Assert.Equal(archive.IsSolid, isSolid);
|
||||
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
|
||||
|
||||
@@ -336,7 +336,7 @@ public class TarArchiveTests : ArchiveTests
|
||||
using Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"));
|
||||
using var reader = ReaderFactory.OpenReader(stream);
|
||||
|
||||
Assert.Equal(ArchiveType.Tar, reader.ArchiveType);
|
||||
Assert.Equal(ArchiveType.Tar, reader.Type);
|
||||
Assert.True(reader.MoveToNextEntry());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class TarReaderAsyncTests : ReaderTests
|
||||
var archiveFullPath = Path.Combine(TEST_ARCHIVES_PATH, "Tar.ContainsRar.tar");
|
||||
using Stream stream = File.OpenRead(archiveFullPath);
|
||||
using var reader = ReaderFactory.OpenReader(stream);
|
||||
Assert.True(reader.ArchiveType == ArchiveType.Tar);
|
||||
Assert.True(reader.Type == ArchiveType.Tar);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TarReaderTests : ReaderTests
|
||||
var archiveFullPath = Path.Combine(TEST_ARCHIVES_PATH, "Tar.ContainsRar.tar");
|
||||
using Stream stream = File.OpenRead(archiveFullPath);
|
||||
using var reader = ReaderFactory.OpenReader(stream);
|
||||
Assert.True(reader.ArchiveType == ArchiveType.Tar);
|
||||
Assert.True(reader.Type == ArchiveType.Tar);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user