mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-25 00:15:15 +00:00
merge fixes and fmt
This commit is contained in:
@@ -51,14 +51,19 @@ namespace SharpCompress.Common
|
||||
return BinaryPrimitives.ReadUInt64LittleEndian(_buffer);
|
||||
}
|
||||
|
||||
public async ValueTask ReadBytesAsync(byte[] bytes, int offset, int count, CancellationToken ct = default)
|
||||
public async ValueTask ReadBytesAsync(
|
||||
byte[] bytes,
|
||||
int offset,
|
||||
int count,
|
||||
CancellationToken ct = default
|
||||
)
|
||||
{
|
||||
await _stream.ReadExactAsync(bytes, offset, count, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async ValueTask SkipAsync(int count, CancellationToken ct = default)
|
||||
{
|
||||
await _stream.SkipAsync( count, ct).ConfigureAwait(false);
|
||||
await _stream.SkipAsync(count, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -56,7 +56,7 @@ internal class DirectoryEntryHeader : ZipFileEntry
|
||||
var name = new byte[nameLength];
|
||||
var extra = new byte[extraLength];
|
||||
var comment = new byte[commentLength];
|
||||
await reader.ReadBytesAsync(name,0 ,nameLength);
|
||||
await reader.ReadBytesAsync(name, 0, nameLength);
|
||||
await reader.ReadBytesAsync(extra, 0, extraLength);
|
||||
await reader.ReadBytesAsync(comment, 0, commentLength);
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ internal class LocalEntryHeader(IArchiveEncoding archiveEncoding)
|
||||
var extraLength = await reader.ReadUInt16Async();
|
||||
var name = new byte[nameLength];
|
||||
var extra = new byte[extraLength];
|
||||
await reader.ReadBytesAsync(name,0 ,nameLength);
|
||||
await reader.ReadBytesAsync(extra, 0, extraLength);
|
||||
await reader.ReadBytesAsync(name, 0, nameLength);
|
||||
await reader.ReadBytesAsync(extra, 0, extraLength);
|
||||
|
||||
ProcessReadData(name, extra);
|
||||
}
|
||||
|
||||
@@ -39,11 +39,10 @@ internal class Zip64DirectoryEndHeader : ZipHeader
|
||||
DirectorySize = (long)await reader.ReadUInt64Async();
|
||||
DirectoryStartOffsetRelativeToDisk = (long)await reader.ReadUInt64Async();
|
||||
var size = (int)(
|
||||
SizeOfDirectoryEndRecord
|
||||
- SIZE_OF_FIXED_HEADER_DATA_EXCEPT_SIGNATURE_AND_SIZE_FIELDS
|
||||
SizeOfDirectoryEndRecord - SIZE_OF_FIXED_HEADER_DATA_EXCEPT_SIGNATURE_AND_SIZE_FIELDS
|
||||
);
|
||||
DataSector = new byte[size];
|
||||
await reader.ReadBytesAsync(DataSector, 0, size);
|
||||
await reader.ReadBytesAsync(DataSector, 0, size);
|
||||
}
|
||||
|
||||
private const int SIZE_OF_FIXED_HEADER_DATA_EXCEPT_SIGNATURE_AND_SIZE_FIELDS = 44;
|
||||
|
||||
@@ -156,7 +156,6 @@ internal sealed class SeekableZipHeaderFactory : ZipHeaderFactory
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static bool IsMatch(Span<byte> haystack, int position, byte[] needle)
|
||||
{
|
||||
for (var i = 0; i < needle.Length; i++)
|
||||
|
||||
@@ -776,11 +776,16 @@ internal sealed class InflateBlocks
|
||||
// update check information
|
||||
if (checkfn != null)
|
||||
{
|
||||
_codec._adler32 = check = Adler32.Calculate(check, window.Memory.Span.Slice(readAt, nBytes));
|
||||
_codec._adler32 = check = Adler32.Calculate(
|
||||
check,
|
||||
window.Memory.Span.Slice(readAt, nBytes)
|
||||
);
|
||||
}
|
||||
|
||||
// copy as far as end of window
|
||||
window.Memory.Span.Slice(readAt, nBytes).CopyTo(_codec.OutputBuffer.AsSpan(_codec.NextOut));
|
||||
window
|
||||
.Memory.Span.Slice(readAt, nBytes)
|
||||
.CopyTo(_codec.OutputBuffer.AsSpan(_codec.NextOut));
|
||||
_codec.NextOut += nBytes;
|
||||
readAt += nBytes;
|
||||
|
||||
@@ -1469,7 +1474,8 @@ internal sealed class InflateCodes
|
||||
}
|
||||
else
|
||||
{
|
||||
s.window.Memory.Span.Slice(r, 2).CopyTo(s.window.Memory.Span.Slice(q));
|
||||
s.window.Memory.Span.Slice(r, 2)
|
||||
.CopyTo(s.window.Memory.Span.Slice(q));
|
||||
q += 2;
|
||||
r += 2;
|
||||
c -= 2;
|
||||
@@ -1497,7 +1503,8 @@ internal sealed class InflateCodes
|
||||
}
|
||||
else
|
||||
{
|
||||
s.window.Memory.Span.Slice(r, e).CopyTo(s.window.Memory.Span.Slice(q));
|
||||
s.window.Memory.Span.Slice(r, e)
|
||||
.CopyTo(s.window.Memory.Span.Slice(q));
|
||||
q += e;
|
||||
r += e;
|
||||
e = 0;
|
||||
@@ -1516,7 +1523,8 @@ internal sealed class InflateCodes
|
||||
}
|
||||
else
|
||||
{
|
||||
s.window.Memory.Span.Slice(r, c).CopyTo(s.window.Memory.Span.Slice(q));
|
||||
s.window.Memory.Span.Slice(r, c)
|
||||
.CopyTo(s.window.Memory.Span.Slice(q));
|
||||
q += c;
|
||||
r += c;
|
||||
c = 0;
|
||||
|
||||
@@ -126,7 +126,6 @@ internal sealed partial class Unpack : BitInput, IRarUnpack
|
||||
|
||||
private FileHeader fileHeader;
|
||||
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (this.window is null)
|
||||
|
||||
@@ -38,7 +38,7 @@ internal class BufferedSubStream : SharpCompressStream, IStreamStack
|
||||
|
||||
private int _cacheOffset;
|
||||
private int _cacheLength;
|
||||
private readonly byte[] _cache = ArrayPool<byte>.Shared.Rent(32 << 10);
|
||||
private readonly byte[] _cache = ArrayPool<byte>.Shared.Rent(32 << 10);
|
||||
private long origin;
|
||||
|
||||
private long BytesLeftToRead { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user