mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-07 05:34:35 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bec2662d23 | ||
|
|
dd35052de9 | ||
|
|
2a630e04b2 | ||
|
|
231b78e096 | ||
|
|
ce6e1d26f4 | ||
|
|
69a25cd142 | ||
|
|
cc2ad7d8d5 |
@@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>sharpcompress</id>
|
||||
<version>0.11.2</version>
|
||||
<version>0.11.3</version>
|
||||
<title>SharpCompress - Pure C# Decompression/Compression</title>
|
||||
<authors>Adam Hathcock</authors>
|
||||
<owners>Adam Hathcock</owners>
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace SharpCompress.Archive.Zip
|
||||
try
|
||||
{
|
||||
ZipHeader header =
|
||||
headerFactory.ReadStreamHeader(stream).FirstOrDefault(x => x != null && x.ZipHeaderType != ZipHeaderType.Split);
|
||||
headerFactory.ReadStreamHeader(stream).FirstOrDefault(x => x.ZipHeaderType != ZipHeaderType.Split);
|
||||
if (header == null)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -45,17 +45,18 @@ namespace SharpCompress.Common.Zip
|
||||
lastEntryHeader = null;
|
||||
uint headerBytes = reader.ReadUInt32();
|
||||
header = ReadHeader(headerBytes, reader);
|
||||
if (header != null) {
|
||||
// entry could be zero bytes so we need to know that.
|
||||
if(header.ZipHeaderType == ZipHeaderType.LocalEntry) {
|
||||
bool isRecording = rewindableStream.IsRecording;
|
||||
if (!isRecording) {
|
||||
rewindableStream.StartRecording();
|
||||
}
|
||||
uint nextHeaderBytes = reader.ReadUInt32();
|
||||
header.HasData = !IsHeader(nextHeaderBytes);
|
||||
rewindableStream.Rewind(!isRecording);
|
||||
|
||||
//entry could be zero bytes so we need to know that.
|
||||
if (header.ZipHeaderType == ZipHeaderType.LocalEntry)
|
||||
{
|
||||
bool isRecording = rewindableStream.IsRecording;
|
||||
if (!isRecording)
|
||||
{
|
||||
rewindableStream.StartRecording();
|
||||
}
|
||||
uint nextHeaderBytes = reader.ReadUInt32();
|
||||
header.HasData = !IsHeader(nextHeaderBytes);
|
||||
rewindableStream.Rewind(!isRecording);
|
||||
}
|
||||
yield return header;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace SharpCompress.Common.Zip
|
||||
return entry;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
throw new NotSupportedException("Unknown header: " + headerBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -670,6 +670,7 @@ namespace SharpCompress.Compressor.Deflate
|
||||
send_bits((tree[c2] & 0xffff), (tree[c2 + 1] & 0xffff));
|
||||
}
|
||||
|
||||
#pragma warning disable 675 // workaround for Visual Studio 2015 compiler bug: https://github.com/dotnet/roslyn/issues/4027
|
||||
internal void send_bits(int value, int length)
|
||||
{
|
||||
int len = length;
|
||||
@@ -677,10 +678,10 @@ namespace SharpCompress.Compressor.Deflate
|
||||
{
|
||||
if (bi_valid > (int) Buf_size - len)
|
||||
{
|
||||
//int val = value;
|
||||
// bi_buf |= (val << bi_valid);
|
||||
int x = (value << bi_valid) & 0xffff;
|
||||
bi_buf = (short)((int)bi_buf | x);
|
||||
|
||||
bi_buf |= (short)((value << bi_valid) & 0xffff);
|
||||
//put_short(bi_buf);
|
||||
pending[pendingCount++] = (byte) bi_buf;
|
||||
pending[pendingCount++] = (byte) (bi_buf >> 8);
|
||||
@@ -691,14 +692,13 @@ namespace SharpCompress.Compressor.Deflate
|
||||
}
|
||||
else
|
||||
{
|
||||
// bi_buf |= (val << bi_valid);
|
||||
int x = (value << bi_valid) & 0xffff;
|
||||
bi_buf = (short)((int)bi_buf | x);
|
||||
|
||||
// bi_buf |= (value) << bi_valid;
|
||||
bi_buf |= (short)((value << bi_valid) & 0xffff);
|
||||
bi_valid += len;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 675
|
||||
|
||||
// Send one empty static block to give enough lookahead for inflate.
|
||||
// This takes 10 bits, of which 7 may remain in the bit buffer.
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;UNSIGNED</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;UNSIGNED</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © Adam Hathcock")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyVersion("0.11.2.0")]
|
||||
[assembly: AssemblyFileVersion("0.11.2.0")]
|
||||
[assembly: AssemblyVersion("0.11.3.0")]
|
||||
[assembly: AssemblyFileVersion("0.11.3.0")]
|
||||
Reference in New Issue
Block a user