mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-25 08:24:58 +00:00
another round of fixes
This commit is contained in:
@@ -31,7 +31,8 @@
|
||||
<!-- Naming things is hard enough -->
|
||||
CA1710;CA1711;CA1720;CA1724;
|
||||
<!-- Aspirational, slowly add -->
|
||||
CA1502;CA1716;NETSDK1206;IDE0017;IDE0040;IDE0044;IDE0051;IDE0052;IDE0060;IDE1006;IDE1007;IDE1033;IDE1036;IDE1040;IDE1041;IDE1045;IDE1050;IDE1051;IDE1055;IDE1060;IDE1063;IDE1070;IDE1071;IDE1075;IDE1080;IDE1090;CA1034;CA1051;CA1063;
|
||||
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;
|
||||
$(NoWarn)
|
||||
</NoWarn
|
||||
>
|
||||
|
||||
@@ -7,7 +7,10 @@ namespace SharpCompress.Archives.GZip;
|
||||
public class GZipArchiveEntry : GZipEntry, IArchiveEntry
|
||||
{
|
||||
internal GZipArchiveEntry(GZipArchive archive, GZipFilePart? part)
|
||||
: base(part) => Archive = archive;
|
||||
: base(part)
|
||||
{
|
||||
Archive = archive;
|
||||
}
|
||||
|
||||
public virtual Stream OpenEntryStream()
|
||||
{
|
||||
|
||||
@@ -12,7 +12,10 @@ internal sealed class FileInfoRarFilePart : SeekableFilePart
|
||||
FileHeader fh,
|
||||
FileInfo fi
|
||||
)
|
||||
: base(mh, fh, volume.Index, volume.Stream, password) => FileInfo = fi;
|
||||
: base(mh, fh, volume.Index, volume.Stream, password)
|
||||
{
|
||||
FileInfo = fi;
|
||||
}
|
||||
|
||||
internal FileInfo FileInfo { get; }
|
||||
|
||||
|
||||
@@ -216,7 +216,10 @@ public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVol
|
||||
private CFileItem? _currentItem;
|
||||
|
||||
internal SevenZipReader(ReaderOptions readerOptions, SevenZipArchive archive)
|
||||
: base(readerOptions, ArchiveType.SevenZip) => _archive = archive;
|
||||
: base(readerOptions, ArchiveType.SevenZip)
|
||||
{
|
||||
_archive = archive;
|
||||
}
|
||||
|
||||
public override SevenZipVolume Volume => _archive.Volumes.Single();
|
||||
|
||||
@@ -266,7 +269,10 @@ public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVol
|
||||
{
|
||||
private readonly string? _password;
|
||||
|
||||
public PasswordProvider(string? password) => _password = password;
|
||||
public PasswordProvider(string? password)
|
||||
{
|
||||
_password = password;
|
||||
}
|
||||
|
||||
public string? CryptoGetTextPassword() => _password;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,10 @@ namespace SharpCompress.Archives.SevenZip;
|
||||
public class SevenZipArchiveEntry : SevenZipEntry, IArchiveEntry
|
||||
{
|
||||
internal SevenZipArchiveEntry(SevenZipArchive archive, SevenZipFilePart part)
|
||||
: base(part) => Archive = archive;
|
||||
: base(part)
|
||||
{
|
||||
Archive = archive;
|
||||
}
|
||||
|
||||
public Stream OpenEntryStream() => FilePart.GetCompressedStream();
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ namespace SharpCompress.Archives.Tar;
|
||||
public class TarArchiveEntry : TarEntry, IArchiveEntry
|
||||
{
|
||||
internal TarArchiveEntry(TarArchive archive, TarFilePart? part, CompressionType compressionType)
|
||||
: base(part, compressionType) => Archive = archive;
|
||||
: base(part, compressionType)
|
||||
{
|
||||
Archive = archive;
|
||||
}
|
||||
|
||||
public virtual Stream OpenEntryStream() => Parts.Single().GetCompressedStream().NotNull();
|
||||
|
||||
|
||||
@@ -29,11 +29,13 @@ public class ZipArchive : AbstractWritableArchive<ZipArchiveEntry, ZipVolume>
|
||||
/// </summary>
|
||||
/// <param name="sourceStream"></param>
|
||||
internal ZipArchive(SourceStream sourceStream)
|
||||
: base(ArchiveType.Zip, sourceStream) =>
|
||||
headerFactory = new SeekableZipHeaderFactory(
|
||||
sourceStream.ReaderOptions.Password,
|
||||
sourceStream.ReaderOptions.ArchiveEncoding
|
||||
);
|
||||
: base(ArchiveType.Zip, sourceStream)
|
||||
{
|
||||
headerFactory = new SeekableZipHeaderFactory(
|
||||
sourceStream.ReaderOptions.Password,
|
||||
sourceStream.ReaderOptions.ArchiveEncoding
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor expects a filepath to an existing file.
|
||||
|
||||
@@ -7,7 +7,10 @@ namespace SharpCompress.Archives.Zip;
|
||||
public class ZipArchiveEntry : ZipEntry, IArchiveEntry
|
||||
{
|
||||
internal ZipArchiveEntry(ZipArchive archive, SeekableZipFilePart? part)
|
||||
: base(part) => Archive = archive;
|
||||
: base(part)
|
||||
{
|
||||
Archive = archive;
|
||||
}
|
||||
|
||||
public virtual Stream OpenEntryStream() => Parts.Single().GetCompressedStream().NotNull();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ internal static class ZipArchiveVolumeFactory
|
||||
{
|
||||
internal static FileInfo? GetFilePart(int index, FileInfo part1) //base the name on the first part
|
||||
{
|
||||
FileInfo? item = null;
|
||||
FileInfo item;
|
||||
|
||||
//load files with zip/zipx first. Swapped to end once loaded in ZipArchive
|
||||
//new style .zip, z01.. | .zipx, zx01 - if the numbers go beyond 99 then they use 100 ...1000 etc
|
||||
@@ -31,7 +31,7 @@ internal static class ZipArchiveVolumeFactory
|
||||
return ArchiveVolumeFactory.GetFilePart(index, part1);
|
||||
}
|
||||
|
||||
if (item != null && item.Exists)
|
||||
if (item.Exists)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -51,24 +51,21 @@ public class ArcEntryHeader
|
||||
return this;
|
||||
}
|
||||
|
||||
private CompressionType GetCompressionType(byte value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
1 or 2 => CompressionType.None,
|
||||
3 => CompressionType.RLE90,
|
||||
4 => CompressionType.Squeezed,
|
||||
5 or 6 or 7 or 8 => CompressionType.Crunched,
|
||||
9 => CompressionType.Squashed,
|
||||
10 => CompressionType.Crushed,
|
||||
11 => CompressionType.Distilled,
|
||||
_ => CompressionType.Unknown,
|
||||
};
|
||||
}
|
||||
private CompressionType GetCompressionType(byte value) =>
|
||||
value switch
|
||||
{
|
||||
1 or 2 => CompressionType.None,
|
||||
3 => CompressionType.RLE90,
|
||||
4 => CompressionType.Squeezed,
|
||||
5 or 6 or 7 or 8 => CompressionType.Crunched,
|
||||
9 => CompressionType.Squashed,
|
||||
10 => CompressionType.Crushed,
|
||||
11 => CompressionType.Distilled,
|
||||
_ => CompressionType.Unknown,
|
||||
};
|
||||
|
||||
public static DateTime ConvertToDateTime(long rawDateTime)
|
||||
{
|
||||
// Convert Unix timestamp to DateTime (UTC)
|
||||
return DateTimeOffset.FromUnixTimeSeconds(rawDateTime).UtcDateTime;
|
||||
}
|
||||
public static DateTime ConvertToDateTime(long rawDateTime) =>
|
||||
|
||||
// Convert Unix timestamp to DateTime (UTC)
|
||||
DateTimeOffset.FromUnixTimeSeconds(rawDateTime).UtcDateTime;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ public class ArchiveEncoding
|
||||
}
|
||||
|
||||
#if !NETFRAMEWORK
|
||||
static ArchiveEncoding() => Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
static ArchiveEncoding()
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
}
|
||||
#endif
|
||||
|
||||
public string Decode(byte[] bytes) => Decode(bytes, 0, bytes.Length);
|
||||
|
||||
@@ -4,7 +4,10 @@ namespace SharpCompress.Common;
|
||||
|
||||
public class ArchiveExtractionEventArgs<T> : EventArgs
|
||||
{
|
||||
internal ArchiveExtractionEventArgs(T entry) => Item = entry;
|
||||
internal ArchiveExtractionEventArgs(T entry)
|
||||
{
|
||||
Item = entry;
|
||||
}
|
||||
|
||||
public T Item { get; }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using SharpCompress.IO;
|
||||
using SharpCompress.Readers;
|
||||
|
||||
|
||||
@@ -4,7 +4,10 @@ namespace SharpCompress.Common;
|
||||
|
||||
public abstract class FilePart
|
||||
{
|
||||
protected FilePart(ArchiveEncoding archiveEncoding) => ArchiveEncoding = archiveEncoding;
|
||||
protected FilePart(ArchiveEncoding archiveEncoding)
|
||||
{
|
||||
ArchiveEncoding = archiveEncoding;
|
||||
}
|
||||
|
||||
internal ArchiveEncoding ArchiveEncoding { get; }
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ public class GZipEntry : Entry
|
||||
{
|
||||
private readonly GZipFilePart? _filePart;
|
||||
|
||||
internal GZipEntry(GZipFilePart? filePart) => _filePart = filePart;
|
||||
internal GZipEntry(GZipFilePart? filePart)
|
||||
{
|
||||
_filePart = filePart;
|
||||
}
|
||||
|
||||
public override CompressionType CompressionType => CompressionType.GZip;
|
||||
|
||||
|
||||
@@ -9,7 +9,10 @@ public class GZipVolume : Volume
|
||||
: base(stream, options, index) { }
|
||||
|
||||
public GZipVolume(FileInfo fileInfo, ReaderOptions options)
|
||||
: base(fileInfo.OpenRead(), options) => options.LeaveStreamOpen = false;
|
||||
: base(fileInfo.OpenRead(), options)
|
||||
{
|
||||
options.LeaveStreamOpen = false;
|
||||
}
|
||||
|
||||
public override bool IsFirstVolume => true;
|
||||
|
||||
|
||||
@@ -12,7 +12,10 @@ internal class CryptKey3 : ICryptKey
|
||||
|
||||
private string _password;
|
||||
|
||||
public CryptKey3(string password) => _password = password ?? "";
|
||||
public CryptKey3(string password)
|
||||
{
|
||||
_password = password ?? "";
|
||||
}
|
||||
|
||||
public ICryptoTransform Transformer(byte[] salt)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,10 @@ internal class MarkHeader : IRarHeader
|
||||
|
||||
public bool IsRar5 { get; }
|
||||
|
||||
private MarkHeader(bool isRar5) => IsRar5 = isRar5;
|
||||
private MarkHeader(bool isRar5)
|
||||
{
|
||||
IsRar5 = isRar5;
|
||||
}
|
||||
|
||||
public HeaderType HeaderType => HeaderType.Mark;
|
||||
|
||||
|
||||
@@ -42,4 +42,8 @@ internal sealed class NewSubHeaderType : IEquatable<NewSubHeaderType>
|
||||
}
|
||||
|
||||
public bool Equals(NewSubHeaderType? other) => other is not null && Equals(other._bytes);
|
||||
|
||||
public override bool Equals(object? obj) => obj is NewSubHeaderType other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => _bytes.GetHashCode();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,10 @@ internal sealed class RarCryptoBinaryReader : RarCrcBinaryReader
|
||||
}
|
||||
|
||||
public RarCryptoBinaryReader(Stream stream, ICryptKey cryptKey, byte[] salt)
|
||||
: base(stream) => _rijndael = new BlockTransformer(cryptKey.Transformer(salt));
|
||||
: base(stream)
|
||||
{
|
||||
_rijndael = new BlockTransformer(cryptKey.Transformer(salt));
|
||||
}
|
||||
|
||||
// track read count ourselves rather than using the underlying stream since we buffer
|
||||
public override long CurrentReadByteCount
|
||||
|
||||
@@ -18,7 +18,10 @@ public abstract class RarVolume : Volume
|
||||
private int _maxCompressionAlgorithm;
|
||||
|
||||
internal RarVolume(StreamingMode mode, Stream stream, ReaderOptions options, int index)
|
||||
: base(stream, options, index) => _headerFactory = new RarHeaderFactory(mode, options);
|
||||
: base(stream, options, index)
|
||||
{
|
||||
_headerFactory = new RarHeaderFactory(mode, options);
|
||||
}
|
||||
|
||||
private ArchiveHeader? ArchiveHeader { get; set; }
|
||||
|
||||
|
||||
@@ -27,8 +27,10 @@ internal class ArchiveDatabase
|
||||
|
||||
internal IPasswordProvider PasswordProvider { get; }
|
||||
|
||||
public ArchiveDatabase(IPasswordProvider passwordProvider) =>
|
||||
PasswordProvider = passwordProvider;
|
||||
public ArchiveDatabase(IPasswordProvider passwordProvider)
|
||||
{
|
||||
PasswordProvider = passwordProvider;
|
||||
}
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
|
||||
@@ -22,5 +22,8 @@ internal class CFileItem
|
||||
public long? StartPos { get; internal set; }
|
||||
public bool IsAnti { get; internal set; }
|
||||
|
||||
internal CFileItem() => HasStream = true;
|
||||
internal CFileItem()
|
||||
{
|
||||
HasStream = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
namespace SharpCompress.Common.SevenZip;
|
||||
using System;
|
||||
|
||||
internal readonly struct CMethodId
|
||||
namespace SharpCompress.Common.SevenZip;
|
||||
|
||||
|
||||
internal readonly struct CMethodId : IEquatable<CMethodId>
|
||||
{
|
||||
public const ulong K_COPY_ID = 0;
|
||||
public const ulong K_LZMA_ID = 0x030101;
|
||||
@@ -14,7 +17,10 @@ internal readonly struct CMethodId
|
||||
|
||||
public readonly ulong _id;
|
||||
|
||||
public CMethodId(ulong id) => _id = id;
|
||||
public CMethodId(ulong id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => _id.GetHashCode();
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@ namespace SharpCompress.Common.SevenZip;
|
||||
|
||||
public class SevenZipEntry : Entry
|
||||
{
|
||||
internal SevenZipEntry(SevenZipFilePart filePart) => FilePart = filePart;
|
||||
internal SevenZipEntry(SevenZipFilePart filePart)
|
||||
{
|
||||
FilePart = filePart;
|
||||
}
|
||||
|
||||
internal SevenZipFilePart FilePart { get; }
|
||||
|
||||
|
||||
@@ -9,7 +9,10 @@ internal sealed class TarHeader
|
||||
{
|
||||
internal static readonly DateTime EPOCH = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
public TarHeader(ArchiveEncoding archiveEncoding) => ArchiveEncoding = archiveEncoding;
|
||||
public TarHeader(ArchiveEncoding archiveEncoding)
|
||||
{
|
||||
ArchiveEncoding = archiveEncoding;
|
||||
}
|
||||
|
||||
internal string? Name { get; set; }
|
||||
internal string? LinkName { get; set; }
|
||||
|
||||
@@ -13,7 +13,10 @@ internal class SeekableZipFilePart : ZipFilePart
|
||||
DirectoryEntryHeader header,
|
||||
Stream stream
|
||||
)
|
||||
: base(header, stream) => _headerFactory = headerFactory;
|
||||
: base(header, stream)
|
||||
{
|
||||
_headerFactory = headerFactory;
|
||||
}
|
||||
|
||||
internal override Stream GetCompressedStream()
|
||||
{
|
||||
|
||||
@@ -16,7 +16,10 @@ internal class StreamingZipHeaderFactory : ZipHeaderFactory
|
||||
ArchiveEncoding archiveEncoding,
|
||||
IEnumerable<ZipEntry>? entries
|
||||
)
|
||||
: base(StreamingMode.Streaming, password, archiveEncoding) => _entries = entries;
|
||||
: base(StreamingMode.Streaming, password, archiveEncoding)
|
||||
{
|
||||
_entries = entries;
|
||||
}
|
||||
|
||||
internal IEnumerable<ZipHeader> ReadStreamHeader(Stream stream)
|
||||
{
|
||||
|
||||
@@ -60,20 +60,16 @@ internal class CBZip2InputStream : Stream, IStreamStack
|
||||
|
||||
void IStreamStack.SetPosition(long position) { }
|
||||
|
||||
private static void Cadvise()
|
||||
{
|
||||
//System.out.Println("CRC Error");
|
||||
throw new InvalidOperationException("BZip2 error");
|
||||
}
|
||||
private static void Cadvise() => throw
|
||||
|
||||
//System.out.Println("CRC Error");
|
||||
new InvalidOperationException("BZip2 error");
|
||||
|
||||
private static void BadBGLengths() => Cadvise();
|
||||
|
||||
private static void BitStreamEOF() => Cadvise();
|
||||
|
||||
private static void CompressedStreamEOF()
|
||||
{
|
||||
throw new InvalidOperationException("BZip2 compressed file ends unexpectedly");
|
||||
}
|
||||
private static void CompressedStreamEOF() => throw new InvalidOperationException("BZip2 compressed file ends unexpectedly");
|
||||
|
||||
private void MakeMaps()
|
||||
{
|
||||
|
||||
@@ -291,7 +291,10 @@ internal class CRC
|
||||
unchecked((int)0xb1f740b4)
|
||||
];
|
||||
|
||||
public CRC() => InitialiseCRC();
|
||||
public CRC()
|
||||
{
|
||||
InitialiseCRC();
|
||||
}
|
||||
|
||||
internal void InitialiseCRC() => globalCrc = unchecked((int)0xffffffff);
|
||||
|
||||
|
||||
@@ -202,20 +202,22 @@ internal sealed partial class DeflateManager
|
||||
|
||||
public static Config Lookup(CompressionLevel level) => Table[(int)level];
|
||||
|
||||
static Config() =>
|
||||
Table =
|
||||
[
|
||||
new Config(0, 0, 0, 0, DeflateFlavor.Store),
|
||||
new Config(4, 4, 8, 4, DeflateFlavor.Fast),
|
||||
new Config(4, 5, 16, 8, DeflateFlavor.Fast),
|
||||
new Config(4, 6, 32, 32, DeflateFlavor.Fast),
|
||||
new Config(4, 4, 16, 16, DeflateFlavor.Slow),
|
||||
new Config(8, 16, 32, 32, DeflateFlavor.Slow),
|
||||
new Config(8, 16, 128, 128, DeflateFlavor.Slow),
|
||||
new Config(8, 32, 128, 256, DeflateFlavor.Slow),
|
||||
new Config(32, 128, 258, 1024, DeflateFlavor.Slow),
|
||||
new Config(32, 258, 258, 4096, DeflateFlavor.Slow)
|
||||
];
|
||||
static Config()
|
||||
{
|
||||
Table =
|
||||
[
|
||||
new Config(0, 0, 0, 0, DeflateFlavor.Store),
|
||||
new Config(4, 4, 8, 4, DeflateFlavor.Fast),
|
||||
new Config(4, 5, 16, 8, DeflateFlavor.Fast),
|
||||
new Config(4, 6, 32, 32, DeflateFlavor.Fast),
|
||||
new Config(4, 4, 16, 16, DeflateFlavor.Slow),
|
||||
new Config(8, 16, 32, 32, DeflateFlavor.Slow),
|
||||
new Config(8, 16, 128, 128, DeflateFlavor.Slow),
|
||||
new Config(8, 32, 128, 256, DeflateFlavor.Slow),
|
||||
new Config(32, 128, 258, 1024, DeflateFlavor.Slow),
|
||||
new Config(32, 258, 258, 4096, DeflateFlavor.Slow)
|
||||
];
|
||||
}
|
||||
|
||||
private static readonly Config[] Table;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using SharpCompress.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.Deflate;
|
||||
|
||||
@@ -1651,8 +1651,10 @@ internal sealed class InflateManager
|
||||
|
||||
public InflateManager() { }
|
||||
|
||||
public InflateManager(bool expectRfc1950HeaderBytes) =>
|
||||
HandleRfc1950HeaderBytes = expectRfc1950HeaderBytes;
|
||||
public InflateManager(bool expectRfc1950HeaderBytes)
|
||||
{
|
||||
HandleRfc1950HeaderBytes = expectRfc1950HeaderBytes;
|
||||
}
|
||||
|
||||
internal bool HandleRfc1950HeaderBytes { get; set; } = true;
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ namespace SharpCompress.Compressors.Deflate64;
|
||||
|
||||
internal sealed class DeflateInput
|
||||
{
|
||||
public DeflateInput(byte[] buffer) => Buffer = buffer;
|
||||
public DeflateInput(byte[] buffer)
|
||||
{
|
||||
Buffer = buffer;
|
||||
}
|
||||
|
||||
public byte[] Buffer { get; }
|
||||
public int Count { get; set; }
|
||||
|
||||
@@ -86,25 +86,13 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override void Flush() => throw new NotImplementedException();
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override void SetLength(long value) => throw new NotImplementedException();
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException();
|
||||
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => false;
|
||||
|
||||
@@ -22,7 +22,10 @@ internal class BCJFilter : Filter
|
||||
private int _prevMask;
|
||||
|
||||
public BCJFilter(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 5) => _pos = 5;
|
||||
: base(isEncoder, baseStream, 5)
|
||||
{
|
||||
_pos = 5;
|
||||
}
|
||||
|
||||
private static bool Test86MsByte(byte b) => b == 0x00 || b == 0xFF;
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@ internal class BCJFilterARM : Filter
|
||||
private int _pos;
|
||||
|
||||
public BCJFilterARM(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 8) => _pos = 8;
|
||||
: base(isEncoder, baseStream, 8)
|
||||
{
|
||||
_pos = 8;
|
||||
}
|
||||
|
||||
protected override int Transform(byte[] buffer, int offset, int count)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,10 @@ internal class BCJFilterARM64 : Filter
|
||||
private int _pos;
|
||||
|
||||
public BCJFilterARM64(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 8) => _pos = 0;
|
||||
: base(isEncoder, baseStream, 8)
|
||||
{
|
||||
_pos = 0;
|
||||
}
|
||||
|
||||
protected override int Transform(byte[] buffer, int offset, int count)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,10 @@ internal class BCJFilterARMT : Filter
|
||||
private int _pos;
|
||||
|
||||
public BCJFilterARMT(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 4) => _pos = 4;
|
||||
: base(isEncoder, baseStream, 4)
|
||||
{
|
||||
_pos = 4;
|
||||
}
|
||||
|
||||
protected override int Transform(byte[] buffer, int offset, int count)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,10 @@ internal class BCJFilterIA64 : Filter
|
||||
];
|
||||
|
||||
public BCJFilterIA64(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 16) => _pos = 0;
|
||||
: base(isEncoder, baseStream, 16)
|
||||
{
|
||||
_pos = 0;
|
||||
}
|
||||
|
||||
protected override int Transform(byte[] buffer, int offset, int count)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,10 @@ internal class BCJFilterPPC : Filter
|
||||
private int _pos;
|
||||
|
||||
public BCJFilterPPC(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 4) => _pos = 0;
|
||||
: base(isEncoder, baseStream, 4)
|
||||
{
|
||||
_pos = 0;
|
||||
}
|
||||
|
||||
protected override int Transform(byte[] buffer, int offset, int count)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,10 @@ internal class BCJFilterRISCV : Filter
|
||||
private int _pos;
|
||||
|
||||
public BCJFilterRISCV(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 8) => _pos = 0;
|
||||
: base(isEncoder, baseStream, 8)
|
||||
{
|
||||
_pos = 0;
|
||||
}
|
||||
|
||||
private int Decode(byte[] buffer, int offset, int count)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,10 @@ internal class BCJFilterSPARC : Filter
|
||||
private int _pos;
|
||||
|
||||
public BCJFilterSPARC(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 4) => _pos = 0;
|
||||
: base(isEncoder, baseStream, 4)
|
||||
{
|
||||
_pos = 0;
|
||||
}
|
||||
|
||||
protected override int Transform(byte[] buffer, int offset, int count)
|
||||
{
|
||||
|
||||
@@ -13,8 +13,9 @@ namespace SharpCompress.Compressors.Filters;
|
||||
[CLSCompliant(false)]
|
||||
public sealed class BranchExecFilter
|
||||
{
|
||||
public enum Alignment : int
|
||||
public enum Alignment
|
||||
{
|
||||
None = 0,
|
||||
ARCH_x86_ALIGNMENT = 1,
|
||||
ARCH_PowerPC_ALIGNMENT = 4,
|
||||
ARCH_IA64_ALIGNMENT = 16,
|
||||
|
||||
@@ -69,7 +69,10 @@ internal class Bcj2DecoderStream : DecoderStream2, IStreamStack
|
||||
|
||||
private uint _prob;
|
||||
|
||||
public StatusDecoder() => _prob = K_BIT_MODEL_TOTAL / 2;
|
||||
public StatusDecoder()
|
||||
{
|
||||
_prob = K_BIT_MODEL_TOTAL / 2;
|
||||
}
|
||||
|
||||
public uint Decode(RangeDecoder decoder)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace SharpCompress.Compressors.LZMA;
|
||||
/// <summary>
|
||||
/// The exception that is thrown when an error in input stream occurs during decoding.
|
||||
/// </summary>
|
||||
internal class DataErrorException : Exception
|
||||
public class DataErrorException : Exception
|
||||
{
|
||||
public DataErrorException()
|
||||
: base("Data Error") { }
|
||||
@@ -15,7 +15,7 @@ internal class DataErrorException : Exception
|
||||
/// <summary>
|
||||
/// The exception that is thrown when the value of an argument is outside the allowable range.
|
||||
/// </summary>
|
||||
internal class InvalidParamException : Exception
|
||||
public class InvalidParamException : Exception
|
||||
{
|
||||
public InvalidParamException()
|
||||
: base("Invalid Parameter") { }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace SharpCompress.Compressors.LZMA;
|
||||
|
||||
@@ -9,7 +8,10 @@ internal static class Log
|
||||
private static readonly Stack<string> INDENT = new();
|
||||
private static bool NEEDS_INDENT = true;
|
||||
|
||||
static Log() => INDENT.Push("");
|
||||
static Log()
|
||||
{
|
||||
INDENT.Push("");
|
||||
}
|
||||
|
||||
public static void PushIndent(string indent = " ") => INDENT.Push(INDENT.Peek() + indent);
|
||||
|
||||
|
||||
@@ -471,34 +471,22 @@ public class LzwStream : Stream, IStreamStack
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current stream supports reading
|
||||
/// </summary>
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return baseInputStream.CanRead; }
|
||||
}
|
||||
public override bool CanRead => baseInputStream.CanRead;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value of false indicating seeking is not supported for this stream.
|
||||
/// </summary>
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
public override bool CanSeek => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value of false indicating that this stream is not writeable.
|
||||
/// </summary>
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
public override bool CanWrite => false;
|
||||
|
||||
/// <summary>
|
||||
/// A value representing the length of the stream in bytes.
|
||||
/// </summary>
|
||||
public override long Length
|
||||
{
|
||||
get { return got; }
|
||||
}
|
||||
public override long Length => got;
|
||||
|
||||
/// <summary>
|
||||
/// The current position within the stream.
|
||||
@@ -507,17 +495,14 @@ public class LzwStream : Stream, IStreamStack
|
||||
/// <exception cref="NotSupportedException">Attempting to set the position</exception>
|
||||
public override long Position
|
||||
{
|
||||
get { return baseInputStream.Position; }
|
||||
set { throw new NotSupportedException("InflaterInputStream Position not supported"); }
|
||||
get => baseInputStream.Position;
|
||||
set => throw new NotSupportedException("InflaterInputStream Position not supported");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the baseInputStream
|
||||
/// </summary>
|
||||
public override void Flush()
|
||||
{
|
||||
baseInputStream.Flush();
|
||||
}
|
||||
public override void Flush() => baseInputStream.Flush();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the position within the current stream
|
||||
@@ -527,10 +512,7 @@ public class LzwStream : Stream, IStreamStack
|
||||
/// <param name="origin">The <see cref="SeekOrigin"/> defining where to seek from.</param>
|
||||
/// <returns>The new position in the stream.</returns>
|
||||
/// <exception cref="NotSupportedException">Any access</exception>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException("Seek not supported");
|
||||
}
|
||||
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException("Seek not supported");
|
||||
|
||||
/// <summary>
|
||||
/// Set the length of the current stream
|
||||
@@ -538,10 +520,7 @@ public class LzwStream : Stream, IStreamStack
|
||||
/// </summary>
|
||||
/// <param name="value">The new length value for the stream.</param>
|
||||
/// <exception cref="NotSupportedException">Any access</exception>
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException("InflaterInputStream SetLength not supported");
|
||||
}
|
||||
public override void SetLength(long value) => throw new NotSupportedException("InflaterInputStream SetLength not supported");
|
||||
|
||||
/// <summary>
|
||||
/// Writes a sequence of bytes to stream and advances the current position
|
||||
@@ -551,10 +530,7 @@ public class LzwStream : Stream, IStreamStack
|
||||
/// <param name="offset">The offset of the first byte to write.</param>
|
||||
/// <param name="count">The number of bytes to write.</param>
|
||||
/// <exception cref="NotSupportedException">Any access</exception>
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotSupportedException("InflaterInputStream Write not supported");
|
||||
}
|
||||
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException("InflaterInputStream Write not supported");
|
||||
|
||||
/// <summary>
|
||||
/// Writes one byte to the current stream and advances the current position
|
||||
@@ -562,10 +538,7 @@ public class LzwStream : Stream, IStreamStack
|
||||
/// </summary>
|
||||
/// <param name="value">The byte to write.</param>
|
||||
/// <exception cref="NotSupportedException">Any access</exception>
|
||||
public override void WriteByte(byte value)
|
||||
{
|
||||
throw new NotSupportedException("InflaterInputStream WriteByte not supported");
|
||||
}
|
||||
public override void WriteByte(byte value) => throw new NotSupportedException("InflaterInputStream WriteByte not supported");
|
||||
|
||||
/// <summary>
|
||||
/// Closes the input stream. When <see cref="IsStreamOwner"></see>
|
||||
|
||||
@@ -548,5 +548,8 @@ internal class PpmContext : Pointer
|
||||
return buffer.ToString();
|
||||
}
|
||||
|
||||
static PpmContext() => UNION_SIZE = Math.Max(FreqData.SIZE, State.SIZE);
|
||||
static PpmContext()
|
||||
{
|
||||
UNION_SIZE = Math.Max(FreqData.SIZE, State.SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@ internal abstract class Pointer
|
||||
/// <summary> Initialize the object with the array (may be null)</summary>
|
||||
/// <param name="mem">the byte array
|
||||
/// </param>
|
||||
internal Pointer(byte[] mem) => Memory = mem;
|
||||
internal Pointer(byte[] mem)
|
||||
{
|
||||
Memory = mem;
|
||||
}
|
||||
|
||||
internal byte[] Memory { get; private set; }
|
||||
|
||||
|
||||
@@ -77,7 +77,10 @@ internal class SubAllocator
|
||||
private RarMemBlock _tempRarMemBlock2;
|
||||
private RarMemBlock _tempRarMemBlock3;
|
||||
|
||||
public SubAllocator() => Clean();
|
||||
public SubAllocator()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
public virtual void Clean() => _subAllocatorSize = 0;
|
||||
|
||||
@@ -438,5 +441,8 @@ internal class SubAllocator
|
||||
return buffer.ToString();
|
||||
}
|
||||
|
||||
static SubAllocator() => UNIT_SIZE = Math.Max(PpmContext.SIZE, RarMemBlock.SIZE);
|
||||
static SubAllocator()
|
||||
{
|
||||
UNIT_SIZE = Math.Max(PpmContext.SIZE, RarMemBlock.SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,10 @@ internal class Allocator
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Allocator() => _memoryNodes = new MemoryNode[INDEX_COUNT];
|
||||
public Allocator()
|
||||
{
|
||||
_memoryNodes = new MemoryNode[INDEX_COUNT];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize or reset the memory allocator (so that the single, large array can be re-used without destroying
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace SharpCompress.Compressors.PPMd.I1;
|
||||
|
||||
/// <summary>
|
||||
@@ -23,7 +25,7 @@ namespace SharpCompress.Compressors.PPMd.I1;
|
||||
/// Note that <see cref="_address"/> is a field rather than a property for performance reasons.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal struct MemoryNode
|
||||
internal struct MemoryNode : IEquatable<MemoryNode>
|
||||
{
|
||||
public uint _address;
|
||||
public byte[] _memory;
|
||||
@@ -232,6 +234,8 @@ internal struct MemoryNode
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public readonly bool Equals(MemoryNode other) => other._address == _address;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace SharpCompress.Compressors.PPMd.I1;
|
||||
/// Note that <see cref="_address"/> is a field rather than a property for performance reasons.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal struct Pointer
|
||||
internal struct Pointer : IEquatable<Pointer>
|
||||
{
|
||||
public uint _address;
|
||||
public byte[] _memory;
|
||||
@@ -349,6 +349,8 @@ internal struct Pointer
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public bool Equals(Pointer other) => other._address == _address;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace SharpCompress.Compressors.PPMd.I1;
|
||||
|
||||
/// <summary>
|
||||
@@ -17,7 +19,7 @@ internal partial class Model
|
||||
/// <summary>
|
||||
/// The structure which represents the current PPM context. This is 12 bytes in size.
|
||||
/// </summary>
|
||||
internal struct PpmContext
|
||||
internal struct PpmContext : IEquatable<PpmContext>
|
||||
{
|
||||
public uint _address;
|
||||
public byte[] _memory;
|
||||
@@ -262,6 +264,8 @@ internal partial class Model
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public bool Equals(PpmContext other) => other._address == _address;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
@@ -577,7 +581,6 @@ internal partial class Model
|
||||
|
||||
private See2Context MakeEscapeFrequency(PpmContext context)
|
||||
{
|
||||
var numberStatistics = (uint)2 * context.NumberStatistics;
|
||||
See2Context see2Context;
|
||||
|
||||
if (context.NumberStatistics != 0xff)
|
||||
@@ -585,7 +588,7 @@ internal partial class Model
|
||||
// Note that context.Flags is always in the range 0 .. 28 (this ensures that the index used for the second
|
||||
// dimension of the see2Contexts array is always in the range 0 .. 31).
|
||||
|
||||
numberStatistics = context.Suffix.NumberStatistics;
|
||||
var numberStatistics = context.Suffix.NumberStatistics;
|
||||
var index1 = _probabilities[context.NumberStatistics + 2] - 3;
|
||||
var index2 =
|
||||
((context.SummaryFrequency > 11 * (context.NumberStatistics + 1)) ? 1 : 0)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace SharpCompress.Compressors.PPMd.I1;
|
||||
|
||||
/// <summary>
|
||||
@@ -15,7 +17,7 @@ namespace SharpCompress.Compressors.PPMd.I1;
|
||||
/// Note that <see cref="_address"/> is a field rather than a property for performance reasons.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal struct PpmState
|
||||
internal struct PpmState : IEquatable<PpmState>
|
||||
{
|
||||
public uint _address;
|
||||
public byte[] _memory;
|
||||
@@ -183,6 +185,8 @@ internal struct PpmState
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public bool Equals(PpmState other) => other._address == _address;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.RLE90;
|
||||
|
||||
@@ -2,7 +2,10 @@ namespace SharpCompress.Compressors.Rar.UnpackV1.Decode;
|
||||
|
||||
internal class AudioVariables
|
||||
{
|
||||
internal AudioVariables() => Dif = new int[11];
|
||||
internal AudioVariables()
|
||||
{
|
||||
Dif = new int[11];
|
||||
}
|
||||
|
||||
internal int[] Dif { get; }
|
||||
internal int ByteCount { get; set; }
|
||||
|
||||
@@ -18,9 +18,11 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable
|
||||
private readonly BitInput Inp;
|
||||
private bool disposed;
|
||||
|
||||
public Unpack() =>
|
||||
// to ease in porting Unpack50.cs
|
||||
Inp = this;
|
||||
public Unpack()
|
||||
{
|
||||
// to ease in porting Unpack50.cs
|
||||
Inp = this;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,10 @@ internal class UnpackFilter
|
||||
public byte Type;
|
||||
public byte Channels;
|
||||
|
||||
internal UnpackFilter() => Program = new VMPreparedProgram();
|
||||
internal UnpackFilter()
|
||||
{
|
||||
Program = new VMPreparedProgram();
|
||||
}
|
||||
|
||||
// TODO uint
|
||||
internal uint uBlockStart
|
||||
|
||||
@@ -56,11 +56,6 @@ internal partial class FragmentedWindow
|
||||
while (Size >= MinSize)
|
||||
{
|
||||
NewMem = new byte[Size];
|
||||
if (NewMem != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Size -= Size / 32;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static SharpCompress.Compressors.Rar.UnpackV2017.PackDef;
|
||||
using static SharpCompress.Compressors.Rar.UnpackV2017.UnpackGlobal;
|
||||
|
||||
@@ -22,7 +22,10 @@ internal class BitInput
|
||||
public bool ExternalBuffer;
|
||||
|
||||
/// <summary> </summary>
|
||||
internal BitInput() => InBuf = new byte[MAX_SIZE];
|
||||
internal BitInput()
|
||||
{
|
||||
InBuf = new byte[MAX_SIZE];
|
||||
}
|
||||
|
||||
internal byte[] InBuf { get; }
|
||||
|
||||
|
||||
@@ -40,9 +40,11 @@ internal sealed class RarVM : BitInput
|
||||
|
||||
private int IP;
|
||||
|
||||
internal RarVM() =>
|
||||
//InitBlock();
|
||||
Mem = null;
|
||||
internal RarVM()
|
||||
{
|
||||
//InitBlock();
|
||||
Mem = null;
|
||||
}
|
||||
|
||||
internal void init() => Mem ??= new byte[VM_MEMSIZE + 4];
|
||||
|
||||
|
||||
@@ -80,25 +80,13 @@ public class ReduceStream : Stream, IStreamStack
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override void Flush() => throw new NotImplementedException();
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override void SetLength(long value) => throw new NotImplementedException();
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException();
|
||||
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => false;
|
||||
|
||||
@@ -18,7 +18,7 @@ internal class BitStream
|
||||
31U,
|
||||
63U,
|
||||
(uint)sbyte.MaxValue,
|
||||
(uint)byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
511U,
|
||||
1023U,
|
||||
2047U,
|
||||
@@ -26,7 +26,7 @@ internal class BitStream
|
||||
8191U,
|
||||
16383U,
|
||||
(uint)short.MaxValue,
|
||||
(uint)ushort.MaxValue
|
||||
ushort.MaxValue
|
||||
];
|
||||
|
||||
public BitStream(byte[] src, int srcLen)
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace SharpCompress.Compressors.Shrink;
|
||||
|
||||
public class HwUnshrink
|
||||
public static class HwUnshrink
|
||||
{
|
||||
private const int MIN_CODE_SIZE = 9;
|
||||
private const int MAX_CODE_SIZE = 13;
|
||||
|
||||
@@ -2,8 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Compressors.RLE90;
|
||||
using SharpCompress.IO;
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@ public class XZHeader
|
||||
public CheckType BlockCheckType { get; private set; }
|
||||
public int BlockCheckSize => 4 << ((((int)BlockCheckType + 2) / 3) - 1);
|
||||
|
||||
public XZHeader(BinaryReader reader) => _reader = reader;
|
||||
public XZHeader(BinaryReader reader)
|
||||
{
|
||||
_reader = reader;
|
||||
}
|
||||
|
||||
public static XZHeader FromStream(Stream stream)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class XZReadOnlyStream : ReadOnlyStream, IStreamStack
|
||||
|
||||
void IStreamStack.SetPosition(long position) { }
|
||||
|
||||
public XZReadOnlyStream(Stream stream)
|
||||
protected XZReadOnlyStream(Stream stream)
|
||||
{
|
||||
BaseStream = stream;
|
||||
if (!BaseStream.CanRead)
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.ZStandard;
|
||||
@@ -59,7 +55,7 @@ internal class ZStandardStream : ZstdSharp.DecompressionStream, IStreamStack
|
||||
/// <exception cref="NotSupportedException">Attempting to set the position</exception>
|
||||
public override long Position
|
||||
{
|
||||
get { return stream.Position; }
|
||||
set { throw new NotSupportedException("InflaterInputStream Position not supported"); }
|
||||
get => stream.Position;
|
||||
set => throw new NotSupportedException("InflaterInputStream Position not supported");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharpCompress.Compressors.ZStandard;
|
||||
|
||||
internal class ZstandardConstants
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
using SharpCompress.Readers.Arc;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace SharpCompress.Factories;
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Archives;
|
||||
using SharpCompress.Compressors.ZStandard;
|
||||
using SharpCompress.Readers;
|
||||
|
||||
namespace SharpCompress.Factories;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace SharpCompress.IO;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace SharpCompress.IO;
|
||||
|
||||
@@ -137,7 +134,7 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
this.ThrowOnDispose = throwOnDispose;
|
||||
_readOnly = !Stream.CanSeek;
|
||||
|
||||
((IStreamStack)this).SetBuffer(bufferSize, forceBuffer);
|
||||
this.SetBuffer(bufferSize, forceBuffer);
|
||||
try
|
||||
{
|
||||
_baseInitialPos = stream.Position;
|
||||
@@ -188,15 +185,9 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
|
||||
public override bool CanWrite => !_readOnly && Stream.CanWrite;
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
Stream.Flush();
|
||||
}
|
||||
public override void Flush() => Stream.Flush();
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { return Stream.Length; }
|
||||
}
|
||||
public override long Length => Stream.Length;
|
||||
|
||||
public override long Position
|
||||
{
|
||||
@@ -205,7 +196,7 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
long pos = _internalPosition; // Stream.Position + _bufferStream.Position - _bufferStream.Length;
|
||||
return pos;
|
||||
}
|
||||
set { Seek(value, SeekOrigin.Begin); }
|
||||
set => Seek(value, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
@@ -310,10 +301,7 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
return _internalPosition;
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
public override void SetLength(long value) => throw new NotSupportedException();
|
||||
|
||||
public override void WriteByte(byte value)
|
||||
{
|
||||
|
||||
@@ -273,12 +273,10 @@ internal static class StackStreamExtensions
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream stack.</param>
|
||||
/// <param name="message">The debug message to write.</param>
|
||||
public static void DebugTrace(this IStreamStack stream, string message)
|
||||
{
|
||||
Debug.WriteLine(
|
||||
$"{GetStreamStackString(stream, false)} : [{stream.GetType().Name}]{message}"
|
||||
);
|
||||
}
|
||||
public static void DebugTrace(this IStreamStack stream, string message) =>
|
||||
Debug.WriteLine(
|
||||
$"{GetStreamStackString(stream, false)} : [{stream.GetType().Name}]{message}"
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the full stream chain as a string, including instance IDs and positions.
|
||||
|
||||
@@ -12,7 +12,10 @@ internal sealed class LazyReadOnlyCollection<T> : ICollection<T>
|
||||
private readonly IEnumerator<T> source;
|
||||
private bool fullyLoaded;
|
||||
|
||||
public LazyReadOnlyCollection(IEnumerable<T> source) => this.source = source.GetEnumerator();
|
||||
public LazyReadOnlyCollection(IEnumerable<T> source)
|
||||
{
|
||||
this.source = source.GetEnumerator();
|
||||
}
|
||||
|
||||
private class LazyLoader : IEnumerator<T>
|
||||
{
|
||||
@@ -20,8 +23,10 @@ internal sealed class LazyReadOnlyCollection<T> : ICollection<T>
|
||||
private bool disposed;
|
||||
private int index = -1;
|
||||
|
||||
internal LazyLoader(LazyReadOnlyCollection<T> lazyReadOnlyCollection) =>
|
||||
this.lazyReadOnlyCollection = lazyReadOnlyCollection;
|
||||
internal LazyLoader(LazyReadOnlyCollection<T> lazyReadOnlyCollection)
|
||||
{
|
||||
this.lazyReadOnlyCollection = lazyReadOnlyCollection;
|
||||
}
|
||||
|
||||
#region IEnumerator<T> Members
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace SharpCompress.Helpers;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Common.Arc;
|
||||
|
||||
@@ -12,7 +8,10 @@ namespace SharpCompress.Readers.Arc;
|
||||
public class ArcReader : AbstractReader<ArcEntry, ArcVolume>
|
||||
{
|
||||
private ArcReader(Stream stream, ReaderOptions options)
|
||||
: base(options, ArchiveType.Arc) => Volume = new ArcVolume(stream, options, 0);
|
||||
: base(options, ArchiveType.Arc)
|
||||
{
|
||||
Volume = new ArcVolume(stream, options, 0);
|
||||
}
|
||||
|
||||
public override ArcVolume Volume { get; }
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ namespace SharpCompress.Readers.GZip;
|
||||
public class GZipReader : AbstractReader<GZipEntry, GZipVolume>
|
||||
{
|
||||
private GZipReader(Stream stream, ReaderOptions options)
|
||||
: base(options, ArchiveType.GZip) => Volume = new GZipVolume(stream, options, 0);
|
||||
: base(options, ArchiveType.GZip)
|
||||
{
|
||||
Volume = new GZipVolume(stream, options, 0);
|
||||
}
|
||||
|
||||
public override GZipVolume Volume { get; }
|
||||
|
||||
|
||||
@@ -15,7 +15,10 @@ internal class MultiVolumeRarReader : RarReader
|
||||
private Stream tempStream;
|
||||
|
||||
internal MultiVolumeRarReader(IEnumerable<Stream> streams, ReaderOptions options)
|
||||
: base(options) => this.streams = streams.GetEnumerator();
|
||||
: base(options)
|
||||
{
|
||||
this.streams = streams.GetEnumerator();
|
||||
}
|
||||
|
||||
protected override void ValidateArchive(RarVolume archive) { }
|
||||
|
||||
|
||||
@@ -9,7 +9,10 @@ internal class SingleVolumeRarReader : RarReader
|
||||
private readonly Stream stream;
|
||||
|
||||
internal SingleVolumeRarReader(Stream stream, ReaderOptions options)
|
||||
: base(options) => this.stream = stream;
|
||||
: base(options)
|
||||
{
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
protected override void ValidateArchive(RarVolume archive)
|
||||
{
|
||||
|
||||
@@ -10,8 +10,14 @@ public class TarWriterOptions : WriterOptions
|
||||
public bool FinalizeArchiveOnClose { get; }
|
||||
|
||||
public TarWriterOptions(CompressionType compressionType, bool finalizeArchiveOnClose)
|
||||
: base(compressionType) => FinalizeArchiveOnClose = finalizeArchiveOnClose;
|
||||
: base(compressionType)
|
||||
{
|
||||
FinalizeArchiveOnClose = finalizeArchiveOnClose;
|
||||
}
|
||||
|
||||
internal TarWriterOptions(WriterOptions options)
|
||||
: this(options.CompressionType, true) => ArchiveEncoding = options.ArchiveEncoding;
|
||||
: this(options.CompressionType, true)
|
||||
{
|
||||
ArchiveEncoding = options.ArchiveEncoding;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,7 @@ public class ZipWriterOptions : WriterOptions
|
||||
/// This is a convenience method that sets the CompressionLevel property for Deflate compression.
|
||||
/// </summary>
|
||||
/// <param name="level">Deflate compression level (0=no compression, 6=default, 9=best compression)</param>
|
||||
public void SetDeflateCompressionLevel(CompressionLevel level)
|
||||
{
|
||||
CompressionLevel = (int)level;
|
||||
}
|
||||
public void SetDeflateCompressionLevel(CompressionLevel level) => CompressionLevel = (int)level;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the compression level for ZStandard compression (1-22).
|
||||
|
||||
Reference in New Issue
Block a user