Internal Fixes, etc. (#20)

* Start removing mixed usages

* Check for directories before opening

* Fix writing

* Kinda fix rebuild

* One more try

* Better internal handling

* Slighty fix a couple more things

* Update RVWorld Compress code to db7d750bba

* Fix build

Co-authored-by: Matt Nadareski <mnadareski@mparticle.com>
This commit is contained in:
Matt Nadareski
2020-04-03 13:19:21 -07:00
committed by GitHub
parent 1de4bc7b18
commit 916d2a3b51
79 changed files with 3377 additions and 2337 deletions

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
}
}
}