rar5: unpack tighten up access modifiers

This commit is contained in:
coderb
2017-12-17 11:55:33 -05:00
parent f450608073
commit c5b8a444f2
3 changed files with 71 additions and 91 deletions

View File

@@ -10,26 +10,26 @@ using SharpCompress.Compressors.Rar.VM;
namespace SharpCompress.Compressors.Rar
{
//!!! internal sealed class Unpack : Unpack20
internal partial class Unpack : BitInput
internal sealed partial class Unpack : BitInput
{
public bool FileExtracted { // Duplicate method
// private boolean ReadEndOfBlock() throws IOException, RarException
// {
// int BitField = getbits();
// boolean NewTable, NewFile = false;
// if ((BitField & 0x8000) != 0) {
// NewTable = true;
// addbits(1);
// } else {
// NewFile = true;
// NewTable = (BitField & 0x4000) != 0;
// addbits(2);
// }
// tablesRead = !NewTable;
// return !(NewFile || NewTable && !readTables());
// }
get; private set; }
// Duplicate method
// private boolean ReadEndOfBlock() throws IOException, RarException
// {
// int BitField = getbits();
// boolean NewTable, NewFile = false;
// if ((BitField & 0x8000) != 0) {
// NewTable = true;
// addbits(1);
// } else {
// NewFile = true;
// NewTable = (BitField & 0x4000) != 0;
// addbits(2);
// }
// tablesRead = !NewTable;
// return !(NewFile || NewTable && !readTables());
// }
public bool FileExtracted { get; private set; }
public long DestSize
{
@@ -57,32 +57,24 @@ namespace SharpCompress.Compressors.Rar
public int PpmEscChar { get; set; }
//UPGRADE_NOTE: Final was removed from the declaration of 'ppm '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly ModelPPM ppm = new ModelPPM();
private readonly RarVM rarVM = new RarVM();
/* Filters code, one entry per filter */
//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'"
// Filters code, one entry per filter
private readonly List<UnpackFilter> filters = new List<UnpackFilter>();
/* Filters stack, several entrances of same filter are possible */
//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'"
// Filters stack, several entrances of same filter are possible
private readonly List<UnpackFilter> prgStack = new List<UnpackFilter>();
/*
* lengths of preceding blocks, one length per filter. Used to reduce size
* required to write block length if lengths are repeating
*/
//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'"
// lengths of preceding blocks, one length per filter. Used to reduce size
// required to write block length if lengths are repeating
private readonly List<int> oldFilterLengths = new List<int>();
private int lastFilter;
private bool tablesRead;
//UPGRADE_NOTE: The initialization of 'unpOldTable' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
private readonly byte[] unpOldTable = new byte[PackDef.HUFF_TABLE_SIZE];
private BlockTypes unpBlockType;
@@ -97,21 +89,11 @@ namespace SharpCompress.Compressors.Rar
private int lowDistRepCount;
public static int[] DBitLengthCounts = {4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 14, 0, 12};
private static readonly int[] DBitLengthCounts = {4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 14, 0, 12};
private FileHeader fileHeader;
public Unpack()
{
window = null;
//externalWindow = false;
suspended = false;
unpAllBuf = false;
unpSomeRead = false;
}
public void init(byte[] window)
private void init(byte[] window)
{
if (window == null)
{
@@ -739,7 +721,7 @@ namespace SharpCompress.Compressors.Rar
}
}
protected internal void unpInitData(bool solid)
private void unpInitData(bool solid)
{
if (!solid)
{
@@ -788,7 +770,7 @@ namespace SharpCompress.Compressors.Rar
else
{
NewFile = true;
NewTable = (BitField & 0x4000) != 0 ? true : false;
NewTable = (BitField & 0x4000) != 0;
AddBits(2);
}
tablesRead = !NewTable;
@@ -942,7 +924,6 @@ namespace SharpCompress.Compressors.Rar
AddBits(16);
}
//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'"
List<Byte> vmCode = new List<Byte>();
for (int I = 0; I < Length; I++)
{
@@ -988,7 +969,6 @@ namespace SharpCompress.Compressors.Rar
Length = B1 * 256 + B2;
}
//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'"
List<Byte> vmCode = new List<Byte>();
for (int I = 0; I < Length; I++)
{
@@ -1241,7 +1221,7 @@ namespace SharpCompress.Compressors.Rar
}
}
public void cleanUp()
private void cleanUp()
{
if (ppm != null)
{

View File

@@ -15,50 +15,50 @@ namespace SharpCompress.Compressors.Rar
{
internal partial class Unpack
{
protected internal int readBorder;
private int readBorder;
protected internal bool suspended;
private bool suspended;
protected internal bool unpAllBuf;
internal bool unpAllBuf;
//protected internal ComprDataIO unpIO;
//private ComprDataIO unpIO;
protected Stream readStream;
protected Stream writeStream;
private Stream readStream;
private Stream writeStream;
protected internal bool unpSomeRead;
internal bool unpSomeRead;
protected internal int readTop;
private int readTop;
protected internal long destUnpSize;
private long destUnpSize;
protected internal byte[] window;
private byte[] window;
protected internal int[] oldDist = new int[4];
private readonly int[] oldDist = new int[4];
protected internal int unpPtr, wrPtr;
private int unpPtr, wrPtr;
protected internal int oldDistPtr;
private int oldDistPtr;
protected internal int[] ChSet = new int[256],
private readonly int[] ChSet = new int[256],
ChSetA = new int[256],
ChSetB = new int[256],
ChSetC = new int[256];
protected internal int[] Place = new int[256],
private readonly int[] Place = new int[256],
PlaceA = new int[256],
PlaceB = new int[256],
PlaceC = new int[256];
protected internal int[] NToPl = new int[256], NToPlB = new int[256], NToPlC = new int[256];
private readonly int[] NToPl = new int[256], NToPlB = new int[256], NToPlC = new int[256];
protected internal int FlagBuf, AvrPlc, AvrPlcB, AvrLn1, AvrLn2, AvrLn3;
private int FlagBuf, AvrPlc, AvrPlcB, AvrLn1, AvrLn2, AvrLn3;
protected internal int Buf60, NumHuf, StMode, LCount, FlagsCnt;
private int Buf60, NumHuf, StMode, LCount, FlagsCnt;
protected internal int Nhfb, Nlzb, MaxDist3;
private int Nhfb, Nlzb, MaxDist3;
protected internal int lastDist, lastLength;
private int lastDist, lastLength;
private const int STARTL1 = 2;
@@ -109,23 +109,23 @@ namespace SharpCompress.Compressors.Rar
private static readonly int[] PosHf4 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0};
internal static int[] ShortLen1 = {1, 3, 4, 4, 5, 6, 7, 8, 8, 4, 4, 5, 6, 6, 4, 0};
private static readonly int[] ShortLen1 = {1, 3, 4, 4, 5, 6, 7, 8, 8, 4, 4, 5, 6, 6, 4, 0};
internal static int[] ShortXor1 =
private static readonly int[] ShortXor1 =
{
0, 0xa0, 0xd0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xc0, 0x80, 0x90, 0x98
, 0x9c, 0xb0
};
internal static int[] ShortLen2 = {2, 3, 3, 3, 4, 4, 5, 6, 6, 4, 4, 5, 6, 6, 4, 0};
private static readonly int[] ShortLen2 = {2, 3, 3, 3, 4, 4, 5, 6, 6, 4, 4, 5, 6, 6, 4, 0};
internal static int[] ShortXor2 =
private static readonly int[] ShortXor2 =
{
0, 0x40, 0x60, 0xa0, 0xd0, 0xe0, 0xf0, 0xf8, 0xfc, 0xc0, 0x80, 0x90, 0x98
, 0x9c, 0xb0
};
protected void unpack15(bool solid)
private void unpack15(bool solid)
{
if (suspended)
{
@@ -223,7 +223,7 @@ namespace SharpCompress.Compressors.Rar
oldUnpWriteBuf();
}
protected bool unpReadBuf()
private bool unpReadBuf()
{
int dataSize = readTop - inAddr;
if (dataSize < 0)
@@ -699,7 +699,7 @@ namespace SharpCompress.Compressors.Rar
return ((Utility.URShift((Num - (I != 0 ? DecTab[I - 1] : 0)), (16 - StartPos))) + PosTab[StartPos]);
}
protected void oldUnpWriteBuf()
private void oldUnpWriteBuf()
{
if (unpPtr != wrPtr)
{

View File

@@ -14,37 +14,37 @@ namespace SharpCompress.Compressors.Rar
{
internal partial class Unpack
{
protected readonly internal MultDecode[] MD = new MultDecode[4];
private readonly MultDecode[] MD = new MultDecode[4];
protected readonly internal byte[] UnpOldTable20 = new byte[PackDef.MC20 * 4];
private readonly byte[] UnpOldTable20 = new byte[PackDef.MC20 * 4];
protected internal int UnpAudioBlock, UnpChannels, UnpCurChannel, UnpChannelDelta;
private int UnpAudioBlock, UnpChannels, UnpCurChannel, UnpChannelDelta;
private readonly AudioVariables[] AudV = new AudioVariables[4];
protected readonly internal LitDecode LD = new LitDecode();
private readonly LitDecode LD = new LitDecode();
protected readonly internal DistDecode DD = new DistDecode();
private readonly DistDecode DD = new DistDecode();
protected readonly internal LowDistDecode LDD = new LowDistDecode();
private readonly LowDistDecode LDD = new LowDistDecode();
protected readonly internal RepDecode RD = new RepDecode();
private readonly RepDecode RD = new RepDecode();
protected readonly internal BitDecode BD = new BitDecode();
private readonly BitDecode BD = new BitDecode();
public static readonly int[] LDecode =
private static readonly int[] LDecode =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48,
56, 64, 80, 96, 112, 128, 160, 192, 224
};
public static readonly byte[] LBits =
private static readonly byte[] LBits =
{
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,
4, 5, 5, 5, 5
};
public static readonly int[] DDecode =
private static readonly int[] DDecode =
{
0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384,
512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384,
@@ -53,18 +53,18 @@ namespace SharpCompress.Compressors.Rar
917504, 983040
};
public static readonly int[] DBits =
private static readonly int[] DBits =
{
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10,
10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 16, 16, 16, 16, 16
, 16, 16, 16, 16, 16, 16, 16
};
public static readonly int[] SDDecode = {0, 4, 8, 16, 32, 64, 128, 192};
private static readonly int[] SDDecode = {0, 4, 8, 16, 32, 64, 128, 192};
public static readonly int[] SDBits = {2, 2, 3, 4, 5, 6, 6, 6};
private static readonly int[] SDBits = {2, 2, 3, 4, 5, 6, 6, 6};
internal void unpack20(bool solid)
private void unpack20(bool solid)
{
int Bits;
@@ -357,7 +357,7 @@ namespace SharpCompress.Compressors.Rar
return (true);
}
protected void unpInitData20(bool Solid)
private void unpInitData20(bool Solid)
{
if (!Solid)
{