mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-24 07:54:39 +00:00
more
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
CA1710;CA1711;CA1720;CA1724;
|
||||
<!-- Aspirational, slowly add -->
|
||||
CA1502;CA1716;NETSDK1206;IDE0017;IDE0032;IDE0040;IDE0044;IDE0051;IDE0052;IDE0060;IDE0251;IDE1006;IDE1007;IDE1033;IDE1036;IDE1040;IDE1041;IDE1045;IDE1050;IDE1051;IDE1055;IDE1060;IDE1063;
|
||||
IDE1070;IDE1071;IDE1075;IDE1080;IDE1090;CA1027;CA1031;CA1032;CA1033;CA1028;CA1034;CA1051;CA1063;CA1069;CA1505;CA1802;CA1814;CA1819;CA1805;CA2225;CA2237;
|
||||
IDE1070;IDE1071;IDE1075;IDE1080;IDE1090;CA1024;CA1027;CA1031;CA1032;CA1033;CA1028;CA1034;CA1051;CA1063;CA1069;CA1505;CA1802;CA1814;CA1819;CA1805;CA2214;CA2225;CA2237;
|
||||
$(NoWarn)
|
||||
</NoWarn
|
||||
>
|
||||
|
||||
@@ -166,7 +166,7 @@ public class GZipArchive : AbstractWritableArchive<GZipArchiveEntry, GZipVolume>
|
||||
bool closeStream
|
||||
)
|
||||
{
|
||||
if (Entries.Any())
|
||||
if (Entries.Count != 0)
|
||||
{
|
||||
throw new InvalidFormatException("Only one entry is allowed in a GZip Archive");
|
||||
}
|
||||
|
||||
@@ -88,8 +88,10 @@ public class RarArchiveEntry : RarEntry, IArchiveEntry
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning disable CA1851
|
||||
var headers = parts.Select(x => x.FileHeader);
|
||||
return !headers.First().IsSplitBefore && !headers.Last().IsSplitAfter;
|
||||
#pragma warning restore CA1851
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ public class ZipArchive : AbstractWritableArchive<ZipArchiveEntry, ZipVolume>
|
||||
|
||||
var streams = stream.Streams.ToList();
|
||||
var idx = 0;
|
||||
if (streams.Count() > 1) //test part 2 - true = multipart not split
|
||||
if (streams.Count > 1) //test part 2 - true = multipart not split
|
||||
{
|
||||
streams[1].Position += 4; //skip the POST_DATA_DESCRIPTOR to prevent an exception
|
||||
var isZip = IsZipFile(streams[1], ReaderOptions.Password, ReaderOptions.BufferSize);
|
||||
|
||||
@@ -33,7 +33,9 @@ public class ArcEntry : Entry
|
||||
public override CompressionType CompressionType =>
|
||||
_filePart?.Header.CompressionMethod ?? CompressionType.Unknown;
|
||||
|
||||
#pragma warning disable CA1065
|
||||
public override long Size => throw new NotImplementedException();
|
||||
#pragma warning restore CA1065
|
||||
|
||||
public override DateTime? LastModifiedTime => null;
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ internal sealed class StreamingZipFilePart : ZipFilePart
|
||||
// If we had TotalIn / TotalOut we could have used them
|
||||
Header.CompressedSize = _decompressionStream.Position;
|
||||
|
||||
if (_decompressionStream is DeflateStream deflateStream)
|
||||
if (_decompressionStream is DeflateStream)
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(0);
|
||||
rewindableStream.StackSeek(0);
|
||||
}
|
||||
|
||||
Skipped = true;
|
||||
|
||||
@@ -175,7 +175,7 @@ internal class StreamingZipHeaderFactory : ZipHeaderFactory
|
||||
&& local_header.CompressedSize == 0
|
||||
&& local_header.UncompressedSize == 0
|
||||
&& local_header.Crc == 0
|
||||
&& local_header.IsDirectory == false
|
||||
&& !local_header.IsDirectory
|
||||
);
|
||||
|
||||
if (dir_header != null)
|
||||
@@ -193,7 +193,7 @@ internal class StreamingZipHeaderFactory : ZipHeaderFactory
|
||||
else if (local_header.Flags.HasFlag(HeaderFlags.UsePostDataDescriptor))
|
||||
{
|
||||
var nextHeaderBytes = reader.ReadUInt32();
|
||||
((IStreamStack)rewindableStream).Rewind(sizeof(uint));
|
||||
rewindableStream.Rewind(sizeof(uint));
|
||||
|
||||
// Check if next data is PostDataDescriptor, streamed file with 0 length
|
||||
header.HasData = !IsHeader(nextHeaderBytes);
|
||||
|
||||
@@ -152,11 +152,9 @@ public sealed class ADCStream : Stream, IStreamStack
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
|
||||
var size = -1;
|
||||
|
||||
if (_outBuffer is null)
|
||||
{
|
||||
size = ADCBase.Decompress(_stream, out _outBuffer);
|
||||
var _ = ADCBase.Decompress(_stream, out _outBuffer);
|
||||
_outPosition = 0;
|
||||
}
|
||||
|
||||
@@ -172,7 +170,7 @@ public sealed class ADCStream : Stream, IStreamStack
|
||||
copied += piece;
|
||||
_position += piece;
|
||||
toCopy -= piece;
|
||||
size = ADCBase.Decompress(_stream, out _outBuffer);
|
||||
int size = ADCBase.Decompress(_stream, out _outBuffer);
|
||||
_outPosition = 0;
|
||||
if (size == 0 || _outBuffer is null || _outBuffer.Length == 0)
|
||||
{
|
||||
|
||||
@@ -130,7 +130,7 @@ public partial class ArcLzwStream : Stream, IStreamStack
|
||||
{
|
||||
Array.Clear(prefix, 0, prefix.Length);
|
||||
clearFlag = true;
|
||||
freeEnt = (ushort)(FIRST - 1);
|
||||
freeEnt = FIRST - 1;
|
||||
|
||||
if (GetCode(reader) is ushort c)
|
||||
{
|
||||
@@ -181,7 +181,9 @@ public partial class ArcLzwStream : Stream, IStreamStack
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => false;
|
||||
public override bool CanWrite => false;
|
||||
#pragma warning disable CA1065
|
||||
public override long Length => throw new NotImplementedException();
|
||||
#pragma warning restore CA1065
|
||||
public override long Position
|
||||
{
|
||||
get => _stream.Position;
|
||||
|
||||
@@ -1306,8 +1306,7 @@ internal sealed class CBZip2OutputStream : Stream, IStreamStack
|
||||
n = block[zptr[unLo] + d + 1] - med;
|
||||
if (n == 0)
|
||||
{
|
||||
var temp = 0;
|
||||
temp = zptr[unLo];
|
||||
var temp = zptr[unLo];
|
||||
zptr[unLo] = zptr[ltLo];
|
||||
zptr[ltLo] = temp;
|
||||
ltLo++;
|
||||
@@ -1330,8 +1329,7 @@ internal sealed class CBZip2OutputStream : Stream, IStreamStack
|
||||
n = block[zptr[unHi] + d + 1] - med;
|
||||
if (n == 0)
|
||||
{
|
||||
var temp = 0;
|
||||
temp = zptr[unHi];
|
||||
var temp = zptr[unHi];
|
||||
zptr[unHi] = zptr[gtHi];
|
||||
zptr[gtHi] = temp;
|
||||
gtHi--;
|
||||
|
||||
@@ -386,7 +386,7 @@ internal class ZlibBaseStream : Stream, IStreamStack
|
||||
{
|
||||
_stream.Flush();
|
||||
//rewind the buffer
|
||||
((IStreamStack)this).Rewind(z.AvailableBytesIn); //unused
|
||||
this.Rewind(z.AvailableBytesIn); //unused
|
||||
z.AvailableBytesIn = 0;
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ internal class ZlibBaseStream : Stream, IStreamStack
|
||||
if (rc == ZlibConstants.Z_STREAM_END && z.AvailableBytesIn != 0 && !_wantCompress)
|
||||
{
|
||||
//rewind the buffer
|
||||
((IStreamStack)this).Rewind(z.AvailableBytesIn); //unused
|
||||
this.Rewind(z.AvailableBytesIn); //unused
|
||||
z.AvailableBytesIn = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
this.DebugConstruct(typeof(ExplodeStream));
|
||||
#endif
|
||||
this.compressedSize = (int)compressedSize;
|
||||
unCompressedSize = (long)uncompressedSize;
|
||||
unCompressedSize = uncompressedSize;
|
||||
this.generalPurposeBitFlag = generalPurposeBitFlag;
|
||||
explode_SetTables();
|
||||
|
||||
@@ -580,7 +580,7 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
|
||||
if ((returnCode = get_tree(arrBitLengthsForCodes, 64)) != 0)
|
||||
{
|
||||
return (int)returnCode;
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
if ((generalPurposeBitFlag & HeaderFlags.Bit1) != 0) /* true if 8K */
|
||||
|
||||
@@ -78,7 +78,7 @@ internal class BCJFilterRISCV : Filter
|
||||
else
|
||||
{
|
||||
uint inst2_rs1 = inst >> 27;
|
||||
if ((uint)(((inst) - 0x3117) << 18) >= ((inst2_rs1) & 0x1D))
|
||||
if (((inst) - 0x3117) << 18 >= ((inst2_rs1) & 0x1D))
|
||||
{
|
||||
i += 4 - 2;
|
||||
continue;
|
||||
@@ -175,7 +175,7 @@ internal class BCJFilterRISCV : Filter
|
||||
else
|
||||
{
|
||||
uint fake_rs1 = inst >> 27;
|
||||
if ((uint)(((inst) - 0x3117) << 18) >= ((fake_rs1) & 0x1D))
|
||||
if (((inst) - 0x3117) << 18 >= ((fake_rs1) & 0x1D))
|
||||
{
|
||||
i += 4 - 2;
|
||||
continue;
|
||||
|
||||
@@ -99,7 +99,7 @@ public sealed class LZipStream : Stream, IStreamStack
|
||||
//total with headers
|
||||
BinaryPrimitives.WriteUInt64LittleEndian(
|
||||
intBuf,
|
||||
(ulong)compressedCount + (ulong)(6 + 20)
|
||||
(ulong)compressedCount + (6 + 20)
|
||||
);
|
||||
_countingWritableSubStream?.Write(intBuf);
|
||||
}
|
||||
|
||||
@@ -141,13 +141,13 @@ public class ReduceStream : Stream, IStreamStack
|
||||
if (nbits > bitBufferCount)
|
||||
{
|
||||
int temp;
|
||||
while (bitBufferCount <= 8 * (int)(4 - 1) && (temp = NEXTBYTE()) != EOF)
|
||||
while (bitBufferCount <= 8 * (4 - 1) && (temp = NEXTBYTE()) != EOF)
|
||||
{
|
||||
bitBuffer |= (ulong)temp << bitBufferCount;
|
||||
bitBufferCount += 8;
|
||||
}
|
||||
}
|
||||
zdest = (byte)(bitBuffer & (ulong)mask_bits[nbits]);
|
||||
zdest = (byte)(bitBuffer & mask_bits[nbits]);
|
||||
bitBuffer >>= nbits;
|
||||
bitBufferCount -= nbits;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ internal class BitStream
|
||||
_bitsLeft += 8;
|
||||
}
|
||||
}
|
||||
result = (int)((long)_bitBuffer & (long)_maskBits[nbits]);
|
||||
result = (int)((long)_bitBuffer & _maskBits[nbits]);
|
||||
_bitBuffer >>= nbits;
|
||||
_bitsLeft -= nbits;
|
||||
return result;
|
||||
|
||||
@@ -80,7 +80,7 @@ public static class HwUnshrink
|
||||
int code,
|
||||
controlCode;
|
||||
|
||||
code = (int)stream.NextBits(codeSize);
|
||||
code = stream.NextBits(codeSize);
|
||||
if (!stream.Advance(codeSize))
|
||||
{
|
||||
nextCode = INVALID_CODE;
|
||||
|
||||
@@ -129,7 +129,7 @@ public class SqueezeStream : Stream, IStreamStack
|
||||
// Unpack the decoded buffer using the RLE class
|
||||
var unpacked = RLE.UnpackRLE(decoded.ToArray());
|
||||
unpacked.CopyTo(buffer, 0);
|
||||
return unpacked.Count();
|
||||
return unpacked.Count;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin) =>
|
||||
|
||||
@@ -99,7 +99,7 @@ public sealed class XZBlock : XZReadOnlyStream
|
||||
private void ConnectStream()
|
||||
{
|
||||
_decomStream = BaseStream;
|
||||
while (Filters.Any())
|
||||
while (Filters.Count > 0)
|
||||
{
|
||||
var filter = Filters.Pop();
|
||||
filter.SetBaseStream(_decomStream);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class XZIndex
|
||||
|
||||
private void VerifyCrc32()
|
||||
{
|
||||
var crc = _reader.ReadLittleEndianUInt32();
|
||||
//var crc = _reader.ReadLittleEndianUInt32();
|
||||
// TODO verify this matches
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SharpCompress.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.ZStandard;
|
||||
@@ -30,7 +31,7 @@ internal class ZStandardStream : ZstdSharp.DecompressionStream, IStreamStack
|
||||
|
||||
internal static bool IsZStandard(Stream stream)
|
||||
{
|
||||
var br = new BinaryReader(stream);
|
||||
using var br = new BinaryReader(stream, Encoding.UTF8, true);
|
||||
var magic = br.ReadUInt32();
|
||||
if (ZstandardConstants.MAGIC != magic)
|
||||
{
|
||||
|
||||
@@ -78,11 +78,11 @@ public abstract class Factory : IFactory
|
||||
|
||||
if (this is IReaderFactory readerFactory)
|
||||
{
|
||||
long pos = ((IStreamStack)stream).GetPosition();
|
||||
long pos = stream.GetPosition();
|
||||
|
||||
if (IsArchive(stream, options.Password, options.BufferSize))
|
||||
{
|
||||
((IStreamStack)stream).StackSeek(pos);
|
||||
stream.StackSeek(pos);
|
||||
reader = readerFactory.OpenReader(stream, options);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -83,20 +83,20 @@ public class GZipFactory
|
||||
{
|
||||
reader = null;
|
||||
|
||||
long pos = ((IStreamStack)rewindableStream).GetPosition();
|
||||
long pos = rewindableStream.GetPosition();
|
||||
|
||||
if (GZipArchive.IsGZipFile(rewindableStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
var testStream = new GZipStream(rewindableStream, CompressionMode.Decompress);
|
||||
if (TarArchive.IsTarFile(testStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
reader = new TarReader(rewindableStream, options, CompressionType.GZip);
|
||||
return true;
|
||||
}
|
||||
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
reader = OpenReader(rewindableStream, options);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class TarFactory
|
||||
)
|
||||
{
|
||||
reader = null;
|
||||
long pos = ((IStreamStack)rewindableStream).GetPosition();
|
||||
long pos = rewindableStream.GetPosition();
|
||||
TestOption? testedOption = null;
|
||||
if (!string.IsNullOrWhiteSpace(options.ExtensionHint))
|
||||
{
|
||||
@@ -192,7 +192,7 @@ public class TarFactory
|
||||
{
|
||||
continue; // Already tested above
|
||||
}
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
reader = TryOption(rewindableStream, options, pos, testOption);
|
||||
if (reader != null)
|
||||
{
|
||||
@@ -212,17 +212,16 @@ public class TarFactory
|
||||
{
|
||||
if (testOption.CanHandle(rewindableStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
var inStream = rewindableStream;
|
||||
rewindableStream.StackSeek(pos);
|
||||
if (testOption.WrapInSharpCompressStream)
|
||||
{
|
||||
inStream = SharpCompressStream.Create(rewindableStream, leaveOpen: true);
|
||||
rewindableStream = SharpCompressStream.Create(rewindableStream, leaveOpen: true);
|
||||
}
|
||||
var testStream = testOption.CreateStream(rewindableStream);
|
||||
|
||||
if (TarArchive.IsTarFile(testStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
return new TarReader(rewindableStream, options, testOption.Type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace SharpCompress.IO;
|
||||
|
||||
@@ -83,7 +84,7 @@ public class DataDescriptorStream : Stream, IStreamStack
|
||||
|
||||
private bool validate_data_descriptor(Stream stream, long size)
|
||||
{
|
||||
var br = new BinaryReader(stream);
|
||||
using var br = new BinaryReader(stream, Encoding.UTF8, true);
|
||||
br.ReadUInt32();
|
||||
br.ReadUInt32(); // CRC32 can be checked if we calculate it
|
||||
var compressedSize = br.ReadUInt32();
|
||||
|
||||
@@ -264,7 +264,6 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
ValidateBufferState();
|
||||
}
|
||||
|
||||
long orig = _internalPosition;
|
||||
long targetPos;
|
||||
// Calculate the absolute target position based on origin
|
||||
switch (origin)
|
||||
|
||||
@@ -4,5 +4,7 @@ namespace SharpCompress.Readers;
|
||||
|
||||
public interface IReaderExtractionListener : IExtractionListener
|
||||
{
|
||||
void FireEntryExtractionProgress(Entry entry, long sizeTransferred, int iterations);
|
||||
#pragma warning disable CA1030
|
||||
void FireEntryExtractionProgress(Entry entry, long sizeTransferred, int iterations);
|
||||
#pragma warning restore CA1030
|
||||
}
|
||||
|
||||
@@ -22,17 +22,15 @@ public static class ReaderFactory
|
||||
|
||||
var bStream = new SharpCompressStream(stream, bufferSize: options.BufferSize);
|
||||
|
||||
long pos = ((IStreamStack)bStream).GetPosition();
|
||||
|
||||
var factories = Factories.Factory.Factories.OfType<Factories.Factory>();
|
||||
long pos = bStream.GetPosition();
|
||||
|
||||
Factory? testedFactory = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(options.ExtensionHint))
|
||||
{
|
||||
testedFactory = factories.FirstOrDefault(a =>
|
||||
a.GetSupportedExtensions()
|
||||
.Contains(options.ExtensionHint, StringComparer.CurrentCultureIgnoreCase)
|
||||
testedFactory = Factory.Factories.OfType<Factories.Factory>().FirstOrDefault(a =>
|
||||
a.GetSupportedExtensions()
|
||||
.Contains(options.ExtensionHint, StringComparer.CurrentCultureIgnoreCase)
|
||||
);
|
||||
if (
|
||||
testedFactory?.TryOpenReader(bStream, options, out var reader) == true
|
||||
@@ -41,16 +39,16 @@ public static class ReaderFactory
|
||||
{
|
||||
return reader;
|
||||
}
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
bStream.StackSeek(pos);
|
||||
}
|
||||
|
||||
foreach (var factory in factories)
|
||||
foreach (var factory in Factory.Factories.OfType<Factories.Factory>())
|
||||
{
|
||||
if (testedFactory == factory)
|
||||
{
|
||||
continue; // Already tested above
|
||||
}
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
bStream.StackSeek(pos);
|
||||
if (factory.TryOpenReader(bStream, options, out var reader) && reader != null)
|
||||
{
|
||||
return reader;
|
||||
|
||||
@@ -56,62 +56,62 @@ public class TarReader : AbstractReader<TarEntry, TarVolume>
|
||||
public static TarReader Open(Stream stream, ReaderOptions? options = null)
|
||||
{
|
||||
stream.CheckNotNull(nameof(stream));
|
||||
options = options ?? new ReaderOptions();
|
||||
options ??= new ReaderOptions();
|
||||
var rewindableStream = new SharpCompressStream(stream);
|
||||
|
||||
long pos = ((IStreamStack)rewindableStream).GetPosition();
|
||||
long pos = rewindableStream.GetPosition();
|
||||
|
||||
if (GZipArchive.IsGZipFile(rewindableStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
var testStream = new GZipStream(rewindableStream, CompressionMode.Decompress);
|
||||
if (TarArchive.IsTarFile(testStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
return new TarReader(rewindableStream, options, CompressionType.GZip);
|
||||
}
|
||||
throw new InvalidFormatException("Not a tar file.");
|
||||
}
|
||||
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
if (BZip2Stream.IsBZip2(rewindableStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
var testStream = new BZip2Stream(rewindableStream, CompressionMode.Decompress, false);
|
||||
if (TarArchive.IsTarFile(testStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
return new TarReader(rewindableStream, options, CompressionType.BZip2);
|
||||
}
|
||||
throw new InvalidFormatException("Not a tar file.");
|
||||
}
|
||||
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
if (ZStandardStream.IsZStandard(rewindableStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
var testStream = new ZStandardStream(rewindableStream);
|
||||
if (TarArchive.IsTarFile(testStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
return new TarReader(rewindableStream, options, CompressionType.ZStandard);
|
||||
}
|
||||
throw new InvalidFormatException("Not a tar file.");
|
||||
}
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
if (LZipStream.IsLZipFile(rewindableStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
var testStream = new LZipStream(rewindableStream, CompressionMode.Decompress);
|
||||
if (TarArchive.IsTarFile(testStream))
|
||||
{
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
return new TarReader(rewindableStream, options, CompressionType.LZip);
|
||||
}
|
||||
throw new InvalidFormatException("Not a tar file.");
|
||||
}
|
||||
|
||||
((IStreamStack)rewindableStream).StackSeek(pos);
|
||||
rewindableStream.StackSeek(pos);
|
||||
return new TarReader(rewindableStream, options, CompressionType.None);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user