Update Compress library from RVWorld latest

This commit is contained in:
Matt Nadareski
2021-01-29 17:18:28 -08:00
parent a26833b8a8
commit 6e8792c361
84 changed files with 4348 additions and 3509 deletions

View File

@@ -60,8 +60,8 @@ namespace Compress.SevenZip.Common
public interface ICoder2
{
void Code(ISequentialInStream []inStreams,
const UInt64 []inSizes,
ISequentialOutStream []outStreams,
const UInt64 []inSizes,
ISequentialOutStream []outStreams,
UInt64 []outSizes,
ICodeProgress progress);
};
@@ -149,4 +149,4 @@ namespace Compress.SevenZip.Common
{
void SetDecoderProperties(byte[] properties);
}
}
}

View File

@@ -97,4 +97,4 @@ namespace Compress.SevenZip.Compress.BZip2
936, 638
};
}
}
}

View File

@@ -1130,4 +1130,4 @@ namespace Compress.SevenZip.Compress.BZip2
}
}
}
}
}

View File

@@ -1982,4 +1982,4 @@ namespace Compress.SevenZip.Compress.BZip2
}
}
}
}
}

View File

@@ -135,4 +135,4 @@ namespace Compress.SevenZip.Compress.BZip2
internal int globalCrc;
}
}
}

View File

@@ -363,4 +363,4 @@ namespace Compress.SevenZip.Compress.LZ
public void SetCutValue(UInt32 cutValue) { _cutValue = cutValue; }
}
}
}

View File

@@ -145,4 +145,4 @@ namespace Compress.SevenZip.Compress.LZ
}
}
}
}
}

View File

@@ -183,4 +183,4 @@ namespace Compress.SevenZip.Compress.LZ
}
}
}
}
}

View File

@@ -71,4 +71,4 @@ namespace Compress.SevenZip.Compress.LZMA
(1 << kNumHighLenBits);
public const uint kMatchMaxLen = kMatchMinLen + kNumLenSymbols - 1;
}
}
}

View File

@@ -387,7 +387,7 @@ namespace Compress.SevenZip.Compress.LZMA
set { }
}
public override void Flush() { }
public override int Read(byte[] buffer, int offset, int count)
public override int Read(byte[] buffer, int offset, int count)
{
return 0;
}
@@ -401,4 +401,4 @@ namespace Compress.SevenZip.Compress.LZMA
public override void SetLength(long value) {}
*/
}
}
}

View File

@@ -876,7 +876,7 @@ namespace Compress.SevenZip.Compress.LZMA
}
}
UInt32 startLen = 2; // speed optimization
UInt32 startLen = 2; // speed optimization
for (UInt32 repIndex = 0; repIndex < Base.kNumRepDistances; repIndex++)
{
@@ -1418,7 +1418,7 @@ namespace Compress.SevenZip.Compress.LZMA
}
static string[] kMatchFinderIDs =
static string[] kMatchFinderIDs =
{
"BT2",
"BT4",
@@ -1544,4 +1544,4 @@ namespace Compress.SevenZip.Compress.LZMA
}
}
}
}

View File

@@ -54,4 +54,4 @@ namespace Compress.SevenZip.Compress.LZMA
};
}
}
}
}

View File

@@ -181,11 +181,11 @@ namespace Compress.SevenZip.Compress.LZMA
toProcess = (int)availableBytes;
outWindow.SetLimit(toProcess);
if (uncompressedChunk)
if(uncompressedChunk)
{
inputPosition += outWindow.CopyStream(inputStream, toProcess);
}
else if (decoder.Code(dictionarySize, outWindow, rangeDecoder)
else if(decoder.Code(dictionarySize, outWindow, rangeDecoder)
&& outputSize < 0)
{
availableBytes = outWindow.AvailableBytes;
@@ -281,10 +281,10 @@ namespace Compress.SevenZip.Compress.LZMA
public override long Seek(long offset, SeekOrigin origin)
{
if (origin != SeekOrigin.Current)
throw new NotImplementedException();
if (origin!=SeekOrigin.Current)
throw new NotImplementedException();
byte[] tmpBuff = new byte[1024];
byte[] tmpBuff=new byte[1024];
long sizeToGo = offset;
while (sizeToGo > 0)
{
@@ -292,7 +292,7 @@ namespace Compress.SevenZip.Compress.LZMA
Read(tmpBuff, 0, sizenow);
sizeToGo -= sizenow;
}
return offset;
}
@@ -315,4 +315,4 @@ namespace Compress.SevenZip.Compress.LZMA
}
}
}
}
}

View File

@@ -883,7 +883,7 @@ namespace Compress.SevenZip.Compress.PPmd.H
charMask[rs.Symbol] = 0;
prevSuccess = 0;
}
for (; ; )
for (;;)
{
State s = tempState1.Initialize(Heap);
int i;
@@ -920,7 +920,7 @@ namespace Compress.SevenZip.Compress.PPmd.H
{
byte symbol;
State ps = tempState2.Initialize(Heap);
for (hiCnt = 0, i = 0, ps.Address = minContext.ps[i]; (hiCnt += ps.Freq) <= count; i++, ps.Address = minContext.ps[i]) ;
for (hiCnt = 0, i = 0, ps.Address = minContext.ps[i]; (hiCnt += ps.Freq) <= count; i++, ps.Address = minContext.ps[i]);
s.Address = ps.Address;
decoder.Decode((uint)(hiCnt - s.Freq), (uint)s.Freq);
see.update();

View File

@@ -305,7 +305,7 @@ namespace Compress.SevenZip.Compress.PPmd.H
// byte[] bytes = model.getSubAlloc().getHeap();
// int p1 = state1.Address;
// int p2 = state2.Address;
//
//
// for (int i = 0; i < StatePtr.size; i++) {
// byte temp = bytes[p1+i];
// bytes[p1+i] = bytes[p2+i];

View File

@@ -73,7 +73,7 @@ namespace Compress.SevenZip.Compress.PPmd.H
internal void AriDecNormalize()
{
// while ((low ^ (low + range)) < TOP || range < BOT && ((range = -low & (BOT - 1)) != 0 ? true : true))
// while ((low ^ (low + range)) < TOP || range < BOT && ((range = -low & (BOT - 1)) != 0 ? true : true))
// {
// code = ((code << 8) | unpackRead.getChar()&0xff)&uintMask;
// range = (range << 8)&uintMask;

View File

@@ -206,7 +206,7 @@ namespace Compress.SevenZip.Compress.PPmd.H
// Bug fixed
freeListPos = heapStart + allocSize;
//UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
//assert(realAllocSize - tempMemBlockPos == RarMemBlock.size): realAllocSize
//assert(realAllocSize - tempMemBlockPos == RarMemBlock.size): realAllocSize
//+ + tempMemBlockPos + + RarMemBlock.size;
// Init freeList

View File

@@ -454,4 +454,4 @@ namespace Compress.SevenZip.Compress.PPmd.I1
#endregion
}
}
}

View File

@@ -33,9 +33,9 @@ namespace Compress.SevenZip.Compress.PPmd.I1
public void RangeEncoderNormalize(Stream stream)
{
while ((low ^ (low + range)) < RangeTop || range < RangeBottom && ((range = (uint)-low & (RangeBottom - 1)) != 0 || true))
while ((low ^ (low + range)) < RangeTop || range < RangeBottom && ((range = (uint) -low & (RangeBottom - 1)) != 0 || true))
{
stream.WriteByte((byte)(low >> 24));
stream.WriteByte((byte) (low >> 24));
range <<= 8;
low <<= 8;
}
@@ -57,7 +57,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
{
for (uint index = 0; index < 4; index++)
{
stream.WriteByte((byte)(low >> 24));
stream.WriteByte((byte) (low >> 24));
low <<= 8;
}
}
@@ -68,14 +68,14 @@ namespace Compress.SevenZip.Compress.PPmd.I1
code = 0;
range = uint.MaxValue;
for (uint index = 0; index < 4; index++)
code = (code << 8) | (byte)stream.ReadByte();
code = (code << 8) | (byte) stream.ReadByte();
}
public void RangeDecoderNormalize(Stream stream)
{
while ((low ^ (low + range)) < RangeTop || range < RangeBottom && ((range = (uint)-low & (RangeBottom - 1)) != 0 || true))
while ((low ^ (low + range)) < RangeTop || range < RangeBottom && ((range = (uint) -low & (RangeBottom - 1)) != 0 || true))
{
code = (code << 8) | (byte)stream.ReadByte();
code = (code << 8) | (byte) stream.ReadByte();
range <<= 8;
low <<= 8;
}
@@ -97,4 +97,4 @@ namespace Compress.SevenZip.Compress.PPmd.I1
range *= HighCount - LowCount;
}
}
}
}

View File

@@ -48,13 +48,13 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// </summary>
public uint Stamp
{
get { return ((uint)Memory[Address]) | ((uint)Memory[Address + 1]) << 8 | ((uint)Memory[Address + 2]) << 16 | ((uint)Memory[Address + 3]) << 24; }
get { return ((uint) Memory[Address]) | ((uint) Memory[Address + 1]) << 8 | ((uint) Memory[Address + 2]) << 16 | ((uint) Memory[Address + 3]) << 24; }
set
{
Memory[Address] = (byte)value;
Memory[Address + 1] = (byte)(value >> 8);
Memory[Address + 2] = (byte)(value >> 16);
Memory[Address + 3] = (byte)(value >> 24);
Memory[Address] = (byte) value;
Memory[Address + 1] = (byte) (value >> 8);
Memory[Address + 2] = (byte) (value >> 16);
Memory[Address + 3] = (byte) (value >> 24);
}
}
@@ -63,13 +63,13 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// </summary>
public MemoryNode Next
{
get { return new MemoryNode(((uint)Memory[Address + 4]) | ((uint)Memory[Address + 5]) << 8 | ((uint)Memory[Address + 6]) << 16 | ((uint)Memory[Address + 7]) << 24, Memory); }
get { return new MemoryNode(((uint) Memory[Address + 4]) | ((uint) Memory[Address + 5]) << 8 | ((uint) Memory[Address + 6]) << 16 | ((uint) Memory[Address + 7]) << 24, Memory); }
set
{
Memory[Address + 4] = (byte)value.Address;
Memory[Address + 5] = (byte)(value.Address >> 8);
Memory[Address + 6] = (byte)(value.Address >> 16);
Memory[Address + 7] = (byte)(value.Address >> 24);
Memory[Address + 4] = (byte) value.Address;
Memory[Address + 5] = (byte) (value.Address >> 8);
Memory[Address + 6] = (byte) (value.Address >> 16);
Memory[Address + 7] = (byte) (value.Address >> 24);
}
}
@@ -78,13 +78,13 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// </summary>
public uint UnitCount
{
get { return ((uint)Memory[Address + 8]) | ((uint)Memory[Address + 9]) << 8 | ((uint)Memory[Address + 10]) << 16 | ((uint)Memory[Address + 11]) << 24; }
get { return ((uint) Memory[Address + 8]) | ((uint) Memory[Address + 9]) << 8 | ((uint) Memory[Address + 10]) << 16 | ((uint) Memory[Address + 11]) << 24; }
set
{
Memory[Address + 8] = (byte)value;
Memory[Address + 9] = (byte)(value >> 8);
Memory[Address + 10] = (byte)(value >> 16);
Memory[Address + 11] = (byte)(value >> 24);
Memory[Address + 8] = (byte) value;
Memory[Address + 9] = (byte) (value >> 8);
Memory[Address + 10] = (byte) (value >> 16);
Memory[Address + 11] = (byte) (value >> 24);
}
}
@@ -157,7 +157,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static MemoryNode operator +(MemoryNode memoryNode, int offset)
{
memoryNode.Address = (uint)(memoryNode.Address + offset * Size);
memoryNode.Address = (uint) (memoryNode.Address + offset * Size);
return memoryNode;
}
@@ -181,7 +181,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static MemoryNode operator -(MemoryNode memoryNode, int offset)
{
memoryNode.Address = (uint)(memoryNode.Address - offset * Size);
memoryNode.Address = (uint) (memoryNode.Address - offset * Size);
return memoryNode;
}
@@ -228,7 +228,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
{
if (obj is MemoryNode)
{
MemoryNode memoryNode = (MemoryNode)obj;
MemoryNode memoryNode = (MemoryNode) obj;
return memoryNode.Address == Address;
}
return base.Equals(obj);
@@ -243,4 +243,4 @@ namespace Compress.SevenZip.Compress.PPmd.I1
return Address.GetHashCode();
}
}
}
}

View File

@@ -816,4 +816,4 @@ namespace Compress.SevenZip.Compress.PPmd.I1
#endregion
}
}
}

View File

@@ -26,4 +26,4 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// </summary>
Freeze = 2
}
}
}

View File

@@ -45,18 +45,18 @@ namespace Compress.SevenZip.Compress.PPmd.I1
{
get
{
#if DEBUG
#if DEBUG
if (Address == 0)
throw new InvalidOperationException("The pointer being indexed is a null pointer.");
#endif
#endif
return Memory[Address + offset];
}
set
{
#if DEBUG
#if DEBUG
if (Address == 0)
throw new InvalidOperationException("The pointer being indexed is a null pointer.");
#endif
#endif
Memory[Address + offset] = value;
}
}
@@ -99,11 +99,11 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static Pointer operator +(Pointer pointer, int offset)
{
#if DEBUG
#if DEBUG
if (pointer.Address == 0)
throw new InvalidOperationException("The pointer is a null pointer.");
#endif
pointer.Address = (uint)(pointer.Address + offset);
#endif
pointer.Address = (uint) (pointer.Address + offset);
return pointer;
}
@@ -115,10 +115,10 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static Pointer operator +(Pointer pointer, uint offset)
{
#if DEBUG
#if DEBUG
if (pointer.Address == 0)
throw new InvalidOperationException("The pointer is a null pointer.");
#endif
#endif
pointer.Address += offset;
return pointer;
}
@@ -130,10 +130,10 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static Pointer operator ++(Pointer pointer)
{
#if DEBUG
#if DEBUG
if (pointer.Address == 0)
throw new InvalidOperationException("The pointer being incremented is a null pointer.");
#endif
#endif
pointer.Address++;
return pointer;
}
@@ -146,11 +146,11 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static Pointer operator -(Pointer pointer, int offset)
{
#if DEBUG
#if DEBUG
if (pointer.Address == 0)
throw new InvalidOperationException("The pointer is a null pointer.");
#endif
pointer.Address = (uint)(pointer.Address - offset);
#endif
pointer.Address = (uint) (pointer.Address - offset);
return pointer;
}
@@ -162,10 +162,10 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static Pointer operator -(Pointer pointer, uint offset)
{
#if DEBUG
#if DEBUG
if (pointer.Address == 0)
throw new InvalidOperationException("The pointer is a null pointer.");
#endif
#endif
pointer.Address -= offset;
return pointer;
}
@@ -177,10 +177,10 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static Pointer operator --(Pointer pointer)
{
#if DEBUG
#if DEBUG
if (pointer.Address == 0)
throw new InvalidOperationException("The pointer being decremented is a null pointer.");
#endif
#endif
pointer.Address--;
return pointer;
}
@@ -193,12 +193,12 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns>The number of bytes between the two pointers.</returns>
public static uint operator -(Pointer pointer1, Pointer pointer2)
{
#if DEBUG
#if DEBUG
if (pointer1.Address == 0)
throw new InvalidOperationException("The pointer to the left of the subtraction operator is a null pointer.");
if (pointer2.Address == 0)
throw new InvalidOperationException("The pointer to the right of the subtraction operator is a null pointer.");
#endif
#endif
return pointer1.Address - pointer2.Address;
}
@@ -210,12 +210,12 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static bool operator <(Pointer pointer1, Pointer pointer2)
{
#if DEBUG
#if DEBUG
if (pointer1.Address == 0)
throw new InvalidOperationException("The pointer to the left of the less than operator is a null pointer.");
if (pointer2.Address == 0)
throw new InvalidOperationException("The pointer to the right of the less than operator is a null pointer.");
#endif
#endif
return pointer1.Address < pointer2.Address;
}
@@ -227,12 +227,12 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static bool operator <=(Pointer pointer1, Pointer pointer2)
{
#if DEBUG
#if DEBUG
if (pointer1.Address == 0)
throw new InvalidOperationException("The pointer to the left of the less than or equal to operator is a null pointer.");
if (pointer2.Address == 0)
throw new InvalidOperationException("The pointer to the right of the less than or equal to operator is a null pointer.");
#endif
#endif
return pointer1.Address <= pointer2.Address;
}
@@ -244,12 +244,12 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static bool operator >(Pointer pointer1, Pointer pointer2)
{
#if DEBUG
#if DEBUG
if (pointer1.Address == 0)
throw new InvalidOperationException("The pointer to the left of the greater than operator is a null pointer.");
if (pointer2.Address == 0)
throw new InvalidOperationException("The pointer to the right of the greater than operator is a null pointer.");
#endif
#endif
return pointer1.Address > pointer2.Address;
}
@@ -261,12 +261,12 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static bool operator >=(Pointer pointer1, Pointer pointer2)
{
#if DEBUG
#if DEBUG
if (pointer1.Address == 0)
throw new InvalidOperationException("The pointer to the left of the greater than or equal to operator is a null pointer.");
if (pointer2.Address == 0)
throw new InvalidOperationException("The pointer to the right of the greater than or equal to operator is a null pointer.");
#endif
#endif
return pointer1.Address >= pointer2.Address;
}
@@ -301,7 +301,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
{
if (obj is Pointer)
{
Pointer pointer = (Pointer)obj;
Pointer pointer = (Pointer) obj;
return pointer.Address == Address;
}
return base.Equals(obj);
@@ -316,4 +316,4 @@ namespace Compress.SevenZip.Compress.PPmd.I1
return Address.GetHashCode();
}
}
}
}

View File

@@ -377,7 +377,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
Coder.LowCount = lowCount;
lowCount += state.Frequency;
Coder.HighCount = lowCount;
for (PpmState p1 = state; --index != 0;)
for (PpmState p1 = state; --index != 0; )
{
do
{
@@ -784,4 +784,4 @@ namespace Compress.SevenZip.Compress.PPmd.I1
return context;
}
}
}
}

View File

@@ -58,13 +58,13 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// </summary>
public Model.PpmContext Successor
{
get { return new Model.PpmContext(((uint)Memory[Address + 2]) | ((uint)Memory[Address + 3]) << 8 | ((uint)Memory[Address + 4]) << 16 | ((uint)Memory[Address + 5]) << 24, Memory); }
get { return new Model.PpmContext(((uint) Memory[Address + 2]) | ((uint) Memory[Address + 3]) << 8 | ((uint) Memory[Address + 4]) << 16 | ((uint) Memory[Address + 5]) << 24, Memory); }
set
{
Memory[Address + 2] = (byte)value.Address;
Memory[Address + 3] = (byte)(value.Address >> 8);
Memory[Address + 4] = (byte)(value.Address >> 16);
Memory[Address + 5] = (byte)(value.Address >> 24);
Memory[Address + 2] = (byte) value.Address;
Memory[Address + 3] = (byte) (value.Address >> 8);
Memory[Address + 4] = (byte) (value.Address >> 16);
Memory[Address + 5] = (byte) (value.Address >> 24);
}
}
@@ -76,7 +76,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public PpmState this[int offset]
{
get { return new PpmState((uint)(Address + offset * Size), Memory); }
get { return new PpmState((uint) (Address + offset * Size), Memory); }
}
/// <summary>
@@ -97,7 +97,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static PpmState operator +(PpmState state, int offset)
{
state.Address = (uint)(state.Address + offset * Size);
state.Address = (uint) (state.Address + offset * Size);
return state;
}
@@ -120,7 +120,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
/// <returns></returns>
public static PpmState operator -(PpmState state, int offset)
{
state.Address = (uint)(state.Address - offset * Size);
state.Address = (uint) (state.Address - offset * Size);
return state;
}
@@ -188,7 +188,7 @@ namespace Compress.SevenZip.Compress.PPmd.I1
{
if (obj is PpmState)
{
PpmState state = (PpmState)obj;
PpmState state = (PpmState) obj;
return state.Address == Address;
}
return base.Equals(obj);
@@ -203,4 +203,4 @@ namespace Compress.SevenZip.Compress.PPmd.I1
return Address.GetHashCode();
}
}
}
}

View File

@@ -32,15 +32,15 @@ namespace Compress.SevenZip.Compress.PPmd.I1
public void Initialize(uint initialValue)
{
Shift = PeriodBitCount - 4;
Summary = (ushort)(initialValue << Shift);
Summary = (ushort) (initialValue << Shift);
Count = 7;
}
public uint Mean()
{
uint value = (uint)(Summary >> Shift);
Summary = (ushort)(Summary - value);
return (uint)(value + ((value == 0) ? 1 : 0));
uint value = (uint) (Summary >> Shift);
Summary = (ushort) (Summary - value);
return (uint) (value + ((value == 0) ? 1 : 0));
}
public void Update()
@@ -48,8 +48,8 @@ namespace Compress.SevenZip.Compress.PPmd.I1
if (Shift < PeriodBitCount && --Count == 0)
{
Summary += Summary;
Count = (byte)(3 << Shift++);
Count = (byte) (3 << Shift++);
}
}
}
}
}

View File

@@ -78,4 +78,4 @@ namespace Compress.SevenZip.Compress.PPmd
}
}
}
}
}

View File

@@ -151,4 +151,4 @@ namespace Compress.SevenZip.Compress.PPmd
model.EncodeBlock(stream, new MemoryStream(buffer, offset, count), false);
}
}
}
}

View File

@@ -119,7 +119,7 @@ namespace Compress.SevenZip.Compress.PPmd
}
/// <summary> Read a int value from the byte array at the given position (Big Endian)
///
///
/// </summary>
/// <param name="array">the array to read from
/// </param>
@@ -142,7 +142,7 @@ namespace Compress.SevenZip.Compress.PPmd
/// <summary> Read a short value from the byte array at the given position (little
/// Endian)
///
///
/// </summary>
/// <param name="array">the array to read from
/// </param>
@@ -157,7 +157,7 @@ namespace Compress.SevenZip.Compress.PPmd
/// <summary> Read an int value from the byte array at the given position (little
/// Endian)
///
///
/// </summary>
/// <param name="array">the array to read from
/// </param>
@@ -171,7 +171,7 @@ namespace Compress.SevenZip.Compress.PPmd
}
/// <summary> Write an int value into the byte array at the given position (Big endian)
///
///
/// </summary>
/// <param name="array">the array
/// </param>
@@ -189,7 +189,7 @@ namespace Compress.SevenZip.Compress.PPmd
/// <summary> Write a short value into the byte array at the given position (little
/// endian)
///
///
/// </summary>
/// <param name="array">the array
/// </param>
@@ -221,7 +221,7 @@ namespace Compress.SevenZip.Compress.PPmd
/// <summary> Write an int value into the byte array at the given position (little
/// endian)
///
///
/// </summary>
/// <param name="array">the array
/// </param>
@@ -464,4 +464,4 @@ namespace Compress.SevenZip.Compress.PPmd
}
#endif
}
}
}

View File

@@ -244,4 +244,4 @@ namespace Compress.SevenZip.Compress.RangeCoder
// ulong GetProcessedSize() {return Stream.GetProcessedSize(); }
}
}
}

View File

@@ -116,4 +116,4 @@ namespace Compress.SevenZip.Compress.RangeCoder
}
}
}
}
}

View File

@@ -22,7 +22,7 @@ namespace Compress.SevenZip.Compress.RangeCoder
public void Encode(Encoder rangeEncoder, UInt32 symbol)
{
UInt32 m = 1;
for (int bitIndex = NumBitLevels; bitIndex > 0;)
for (int bitIndex = NumBitLevels; bitIndex > 0; )
{
bitIndex--;
UInt32 bit = (symbol >> bitIndex) & 1;
@@ -47,7 +47,7 @@ namespace Compress.SevenZip.Compress.RangeCoder
{
UInt32 price = 0;
UInt32 m = 1;
for (int bitIndex = NumBitLevels; bitIndex > 0;)
for (int bitIndex = NumBitLevels; bitIndex > 0; )
{
bitIndex--;
UInt32 bit = (symbol >> bitIndex) & 1;
@@ -154,4 +154,4 @@ namespace Compress.SevenZip.Compress.RangeCoder
return symbol;
}
}
}
}

View File

@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Interop = Zstandard.Net.ZstandardInterop;
using Interop = Compress.SevenZip.Compress.ZSTD.ZstandardInterop;
namespace Zstandard.Net
namespace Compress.SevenZip.Compress.ZSTD
{
/// <summary>
/// A Zstandard dictionary improves the compression ratio and speed on small data dramatically.
@@ -38,7 +38,7 @@ namespace Zstandard.Net
/// <param name="dictionaryPath">The dictionary path.</param>
public ZstandardDictionary(string dictionaryPath)
{
this.dictionary = File.ReadAllBytes(dictionaryPath);
this.dictionary = System.IO.File.ReadAllBytes(dictionaryPath);
}
/// <summary>

View File

@@ -2,7 +2,7 @@
using System.IO;
using System.Runtime.InteropServices;
namespace Zstandard.Net
namespace Compress.SevenZip.Compress.ZSTD
{
internal static class ZstandardInterop
{

View File

@@ -2,9 +2,9 @@
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using Interop = Zstandard.Net.ZstandardInterop;
using Interop = Compress.SevenZip.Compress.ZSTD.ZstandardInterop;
namespace Zstandard.Net
namespace Compress.SevenZip.Compress.ZSTD
{
/// <summary>
/// Provides methods and properties for compressing and decompressing streams by using the Zstandard algorithm.
@@ -32,7 +32,7 @@ namespace Zstandard.Net
private Interop.Buffer outputBuffer = new Interop.Buffer();
private Interop.Buffer inputBuffer = new Interop.Buffer();
/// <summary>
/// Initializes a new instance of the <see cref="ZstandardStream"/> class by using the specified stream and compression mode, and optionally leaves the stream open.
/// </summary>
@@ -238,7 +238,7 @@ namespace Zstandard.Net
{
var inputSize = this.dataSize - this.dataPosition;
// read data from input stream
// read data from input stream
if (inputSize <= 0 && !this.dataDepleted && !this.dataSkipRead)
{
this.dataSize = this.stream.Read(this.data, 0, (int)this.zstreamInputSize);

View File

@@ -51,7 +51,7 @@ namespace Compress.SevenZip.Filters
code = 0;
range = 0xFFFFFFFF;
byte[] controlbuf = new byte[5];
byte[] controlbuf=new byte[5];
control.Read(controlbuf, 0, 5);
for (i = 0; i < 5; i++)
@@ -139,7 +139,7 @@ namespace Compress.SevenZip.Filters
if (range < kTopValue)
{
range <<= 8;
code = (code << 8) | (byte)control.ReadByte();
code = (code << 8) | (byte)control.ReadByte();
}
prevByte = b;
}
@@ -201,4 +201,4 @@ namespace Compress.SevenZip.Filters
throw new NotImplementedException();
}
}
}
}

View File

@@ -4,7 +4,7 @@ namespace Compress.SevenZip.Filters
{
public class BCJFilter : Filter
{
private static readonly bool[] MASK_TO_ALLOWED_STATUS = new bool[] { true, true, true, false, true, false, false, false };
private static readonly bool[] MASK_TO_ALLOWED_STATUS = new bool[] {true, true, true, false, true, false, false, false};
private static readonly int[] MASK_TO_BIT_NUMBER = new int[] { 0, 1, 2, 2, 3, 3, 3, 3 };
private int pos;
@@ -26,24 +26,18 @@ namespace Compress.SevenZip.Filters
int end = offset + count - 5;
int i;
for (i = offset; i <= end; ++i)
{
for (i = offset; i <= end; ++i) {
if ((buffer[i] & 0xFE) != 0xE8)
continue;
prevPos = i - prevPos;
if ((prevPos & ~3) != 0)
{ // (unsigned)prevPos > 3
if ((prevPos & ~3) != 0) { // (unsigned)prevPos > 3
prevMask = 0;
}
else
{
} else {
prevMask = (prevMask << (prevPos - 1)) & 7;
if (prevMask != 0)
{
if (prevMask != 0) {
if (!MASK_TO_ALLOWED_STATUS[prevMask] || test86MSByte(
buffer[i + 4 - MASK_TO_BIT_NUMBER[prevMask]]))
{
buffer[i + 4 - MASK_TO_BIT_NUMBER[prevMask]])) {
prevPos = i;
prevMask = (prevMask << 1) | 1;
continue;
@@ -53,15 +47,13 @@ namespace Compress.SevenZip.Filters
prevPos = i;
if (test86MSByte(buffer[i + 4]))
{
if (test86MSByte(buffer[i + 4])) {
int src = buffer[i + 1]
| (buffer[i + 2] << 8)
| (buffer[i + 3] << 16)
| (buffer[i + 4] << 24);
int dest;
while (true)
{
while (true) {
if (isEncoder)
dest = src + (pos + i - offset);
else
@@ -82,9 +74,7 @@ namespace Compress.SevenZip.Filters
buffer[i + 3] = (byte)(dest >> 16);
buffer[i + 4] = (byte)(~(((dest >> 24) & 1) - 1));
i += 4;
}
else
{
} else {
prevMask = (prevMask << 1) | 1;
}
}
@@ -97,4 +87,4 @@ namespace Compress.SevenZip.Filters
return i;
}
}
}
}

View File

@@ -97,4 +97,4 @@ namespace Compress.SevenZip.Filters
}
}
}
}
}

View File

@@ -149,7 +149,7 @@ namespace Compress.SevenZip.Filters
while (seekToGo > 0)
{
long get = seekToGo > bufferSize ? bufferSize : seekToGo;
Read(seekBuffer, 0, (int)get);
Read(seekBuffer, 0, (int) get);
seekToGo -= get;
}
return position;
@@ -168,4 +168,4 @@ namespace Compress.SevenZip.Filters
protected abstract int Transform(byte[] buffer, int offset, int count);
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Compress.SevenZip.Structure;
@@ -29,6 +30,7 @@ namespace Compress.SevenZip
public byte[] CRC;
public int StreamIndex;
public ulong StreamOffset;
public long LastModified;
public ZipReturn FileStatus = ZipReturn.ZipUntested;
}
@@ -46,7 +48,7 @@ namespace Compress.SevenZip
private long _baseOffset;
public string ZipFilename => _zipFileInfo != null ? _zipFileInfo.FullName : string.Empty;
public string ZipFilename => _zipFileInfo != null ? _zipFileInfo.FullName : "";
public long TimeStamp => _zipFileInfo?.LastWriteTime ?? 0;
@@ -89,6 +91,11 @@ namespace Compress.SevenZip
return _localFiles[i].CRC;
}
public long LastModified(int i)
{
return _localFiles[i].LastModified;
}
public void ZipFileCloseFailed()
{
switch (ZipOpen)

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Compress.SevenZip.Structure;
@@ -161,10 +162,15 @@ namespace Compress.SevenZip
}
}
if (_header.FileInfo.TimeLastWrite != null)
{
lf.LastModified = DateTime.FromFileTimeUtc((long)_header.FileInfo.TimeLastWrite[i]).Ticks;
}
localFiles.Add(lf);
}
}
}
}
}

View File

@@ -6,9 +6,9 @@ using System.IO.Compression;
using Compress.SevenZip.Compress.BZip2;
using Compress.SevenZip.Compress.LZMA;
using Compress.SevenZip.Compress.PPmd;
using Compress.SevenZip.Compress.ZSTD;
using Compress.SevenZip.Filters;
using Compress.SevenZip.Structure;
using Zstandard.Net;
using FileStream = RVIO.FileStream;
namespace Compress.SevenZip
@@ -50,6 +50,11 @@ namespace Compress.SevenZip
ZipFileCloseReadStream();
_streamIndex = thisStreamIndex;
if (_header.StreamsInfo==null)
{
stream = null;
return ZipReturn.ZipGood;
}
Folder folder = _header.StreamsInfo.Folders[_streamIndex];
@@ -192,7 +197,7 @@ namespace Compress.SevenZip
return ZipReturn.ZipGood;
}
catch (Exception e)
catch (Exception)
{
return ZipReturn.ZipErrorGettingDataStream;
}
@@ -224,18 +229,21 @@ namespace Compress.SevenZip
{
if (_streamIndex != -1)
{
Folder folder = _header.StreamsInfo.Folders[_streamIndex];
foreach (Coder c in folder.Coders)
if (_header.StreamsInfo != null)
{
Stream ds = c?.DecoderStream;
if (ds == null)
Folder folder = _header.StreamsInfo.Folders[_streamIndex];
foreach (Coder c in folder.Coders)
{
continue;
Stream ds = c?.DecoderStream;
if (ds == null)
{
continue;
}
ds.Close();
ds.Dispose();
c.DecoderStream = null;
}
ds.Close();
ds.Dispose();
c.DecoderStream = null;
}
}
_streamIndex = -1;
@@ -257,4 +265,4 @@ namespace Compress.SevenZip
}
}
}
}

View File

@@ -25,7 +25,7 @@ namespace Compress.SevenZip
ZipStatus = ZipStatus.TrrntZip;
}
private bool IsRomVault7Z(long testBaseOffset, ulong testHeaderPos, ulong testHeaderLength, uint testHeaderCRC)
private bool IsRomVault7Z(long testBaseOffset,ulong testHeaderPos,ulong testHeaderLength,uint testHeaderCRC)
{
long length = _zipFs.Length;
if (length < 32)
@@ -60,7 +60,7 @@ namespace Compress.SevenZip
if (headerCRC != testHeaderCRC)
return false;
if (headerOffset != testHeaderPos + (ulong)testBaseOffset)
if (headerOffset != testHeaderPos+(ulong)testBaseOffset)
return false;
return headerSize == testHeaderLength;
@@ -154,4 +154,4 @@ namespace Compress.SevenZip
}
}
}
}

View File

@@ -99,7 +99,7 @@ namespace Compress.SevenZip
// do nothing here for 7zip
}
public ZipReturn ZipFileOpenWriteStream(bool raw, bool trrntzip, string filename, ulong uncompressedSize, ushort compressionMethod, uint? datetime, out Stream stream)
public ZipReturn ZipFileOpenWriteStream(bool raw, bool trrntzip, string filename, ulong uncompressedSize, ushort compressionMethod, out Stream stream, TimeStamps dateTime)
{
return ZipFileOpenWriteStream(filename, uncompressedSize, out stream);
}
@@ -173,4 +173,4 @@ namespace Compress.SevenZip
return DictionarySizes[DictionarySizes.Length - 1];
}
}
}
}

View File

@@ -1,9 +1,9 @@
using System.IO;
using System.Text;
using Compress.SevenZip.Compress.LZMA;
using Compress.SevenZip.Compress.ZSTD;
using Compress.SevenZip.Structure;
using Compress.Utils;
using Zstandard.Net;
namespace Compress.SevenZip
{
@@ -290,4 +290,4 @@ namespace Compress.SevenZip
}
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace Compress.SevenZip.Structure
@@ -10,6 +11,9 @@ namespace Compress.SevenZip.Structure
public bool[] EmptyStreamFlags;
public bool[] EmptyFileFlags;
public uint[] Attributes;
public ulong[] TimeCreation;
public ulong[] TimeLastAccess;
public ulong[] TimeLastWrite;
public void Read(BinaryReader br)
{
@@ -67,9 +71,13 @@ namespace Compress.SevenZip.Structure
continue;
case HeaderProperty.kCreationTime:
TimeCreation = Util.ReadUInt64Def(br, size);
continue;
case HeaderProperty.kLastAccessTime:
TimeLastAccess = Util.ReadUInt64Def(br, size);
continue;
case HeaderProperty.kLastWriteTime:
br.ReadBytes((int)bytessize);
TimeLastWrite = Util.ReadUInt64Def(br, size);
continue;
case HeaderProperty.kDummy:

View File

@@ -26,9 +26,9 @@ namespace Compress.SevenZip.Structure
ulong streamPosition = 0;
for (; ; )
for (;;)
{
HeaderProperty hp = (HeaderProperty)br.ReadByte();
HeaderProperty hp = (HeaderProperty) br.ReadByte();
switch (hp)
{
case HeaderProperty.kSize:
@@ -60,12 +60,12 @@ namespace Compress.SevenZip.Structure
public static void Write(BinaryWriter bw, ulong packPosition, PackedStreamInfo[] packedStreams)
{
ulong numPackStreams = (ulong)packedStreams.Length;
bw.Write((byte)HeaderProperty.kPackInfo);
ulong numPackStreams = (ulong) packedStreams.Length;
bw.Write((byte) HeaderProperty.kPackInfo);
bw.WriteEncodedUInt64(packPosition);
bw.WriteEncodedUInt64(numPackStreams);
bw.Write((byte)HeaderProperty.kSize);
bw.Write((byte) HeaderProperty.kSize);
ulong streamPosition = 0;
for (ulong i = 0; i < numPackStreams; i++)
{
@@ -77,14 +77,14 @@ namespace Compress.SevenZip.Structure
// Only checking the first CRC assuming all the reset will be the same
if (packedStreams[0].Crc != null)
{
bw.Write((byte)HeaderProperty.kCRC);
bw.Write((byte) HeaderProperty.kCRC);
for (ulong i = 0; i < numPackStreams; i++)
{
bw.WriteEncodedUInt64(packedStreams[i].Crc ?? 0);
}
}
bw.Write((byte)HeaderProperty.kEnd);
bw.Write((byte) HeaderProperty.kEnd);
}

View File

@@ -5,7 +5,7 @@ namespace Compress.SevenZip.Structure
{
internal class SignatureHeader
{
private static readonly byte[] Signature = { (byte)'7', (byte)'z', 0xBC, 0xAF, 0x27, 0x1C };
private static readonly byte[] Signature = {(byte) '7', (byte) 'z', 0xBC, 0xAF, 0x27, 0x1C};
private byte _major;
private byte _minor;
@@ -38,7 +38,7 @@ namespace Compress.SevenZip.Structure
long pos = br.BaseStream.Position;
byte[] mainHeader = new byte[8 + 8 + 4];
br.BaseStream.Read(mainHeader, 0, mainHeader.Length);
if (!Utils.CRC.VerifyDigest(_startHeaderCRC, mainHeader, 0, (uint)mainHeader.Length))
if (!Utils.CRC.VerifyDigest(_startHeaderCRC, mainHeader, 0, (uint) mainHeader.Length))
{
return false;
}
@@ -61,18 +61,18 @@ namespace Compress.SevenZip.Structure
//ArchiveVersion
//{
bw.Write((byte)0); // BYTE Major
bw.Write((byte)3); // BYTE Minor
bw.Write((byte) 0); // BYTE Major
bw.Write((byte) 3); // BYTE Minor
//};
_crcOffset = bw.BaseStream.Position;
bw.Write((uint)0); //HeaderCRC
bw.Write((uint) 0); //HeaderCRC
//StartHeader
//{
bw.Write((ulong)0); //NextHeaderOffset
bw.Write((ulong)0); //NextHeaderSize
bw.Write((uint)0); //NextHeaderCRC
bw.Write((ulong) 0); //NextHeaderOffset
bw.Write((ulong) 0); //NextHeaderSize
bw.Write((uint) 0); //NextHeaderCRC
//}
BaseOffset = bw.BaseStream.Position;
@@ -86,9 +86,9 @@ namespace Compress.SevenZip.Structure
byte[] sigHeaderBytes;
using (MemoryStream sigHeaderMem = new MemoryStream())
{
using (BinaryWriter sigHeaderBw = new BinaryWriter(sigHeaderMem, Encoding.UTF8, true))
using (BinaryWriter sigHeaderBw = new BinaryWriter(sigHeaderMem,Encoding.UTF8,true))
{
sigHeaderBw.Write((ulong)((long)headerpos - BaseOffset)); //NextHeaderOffset
sigHeaderBw.Write((ulong) ((long) headerpos - BaseOffset)); //NextHeaderOffset
sigHeaderBw.Write(headerLength); //NextHeaderSize
sigHeaderBw.Write(headerCRC); //NextHeaderCRC
@@ -98,7 +98,7 @@ namespace Compress.SevenZip.Structure
}
}
uint sigHeaderCRC = Utils.CRC.CalculateDigest(sigHeaderBytes, 0, (uint)sigHeaderBytes.Length);
uint sigHeaderCRC = Utils.CRC.CalculateDigest(sigHeaderBytes, 0, (uint) sigHeaderBytes.Length);
bw.BaseStream.Position = _crcOffset;
bw.Write(sigHeaderCRC); //Header CRC

View File

@@ -7,7 +7,7 @@ namespace Compress.SevenZip.Structure
{
public ulong UnpackedSize;
public uint? Crc;
public void Report(ref StringBuilder sb)
{
sb.AppendLine($" Crc = {Crc.ToHex()} , Size = {UnpackedSize}");