Skip to content

Commit 5f5a7fd

Browse files
Fixed Bug Cutting Off File
-Fixed a bug for the YAY0 and YAZ0 algorithms that would cause the file to suddenly end under certain conditions. As of now, it should continue until the full file is written. -Minor typo corrected
1 parent 29249f0 commit 5f5a7fd

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

PeepsCompress/PeepsCompress/Algorithm Classes/MIO0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public byte[] buildMIO0CompressedBlock(ref List<byte> layoutBits, ref List<byte>
262262

263263
compressedOffset += layoutBytes.Count;
264264

265-
//add final compresseed offset
265+
//add final compressed offset
266266
byte[] compressedOffsetArray = BitConverter.GetBytes(compressedOffset);
267267
Array.Reverse(compressedOffsetArray);
268268
finalMIO0Block.AddRange(compressedOffsetArray);

PeepsCompress/PeepsCompress/Algorithm Classes/YAY0.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public byte[] buildYAY0CompressedBlock(ref List<byte> layoutBits, ref List<byte>
124124
int compressedInt = ((adjustedLength << 12) | adjustedOffset - 1);
125125

126126
byte[] compressed2Byte = new byte[2];
127-
compressed2Byte[0] = (byte)(compressedInt & 0XFF);
127+
compressed2Byte[0] = (byte)(compressedInt & 0xFF);
128128
compressed2Byte[1] = (byte)((compressedInt >> 8) & 0xFF);
129129

130130
compressedDataBytes.Add(compressed2Byte[1]);
@@ -144,7 +144,7 @@ public byte[] buildYAY0CompressedBlock(ref List<byte> layoutBits, ref List<byte>
144144

145145
compressedOffset += layoutBytes.Count;
146146

147-
//add final compresseed offset
147+
//add final compressed offset
148148
byte[] compressedOffsetArray = BitConverter.GetBytes(compressedOffset);
149149
Array.Reverse(compressedOffsetArray);
150150
finalYAY0Block.AddRange(compressedOffsetArray);
@@ -173,7 +173,7 @@ public byte[] buildYAY0CompressedBlock(ref List<byte> layoutBits, ref List<byte>
173173
{
174174
BitArray arrayOfBits = new BitArray(new byte[1] { layoutBytes[i] });
175175

176-
for (int j = 7; j > -1 && finalYAY0Block.Count < decompressedSize; j--)
176+
for (int j = 7; ((j > -1) && (uncompressedData.Count > 0) && (compressedDataBytes.Count > 0)) ; j--)
177177
{
178178
if (arrayOfBits[j] == true)
179179
{

PeepsCompress/PeepsCompress/Algorithm Classes/YAZ0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public byte[] buildYAZ0CompressedBlock(ref List<byte> layoutBits, ref List<byte>
143143

144144
BitArray arrayOfBits = new BitArray(new byte[1] { layoutBytes[i] });
145145

146-
for (int j = 7; j > -1 && finalYAZ0Block.Count < decompressedSize; j--)
146+
for (int j = 7; ((j > -1) && (uncompressedData.Count > 0) && (compressedDataBytes.Count > 0)); j--)
147147
{
148148
if(arrayOfBits[j] == true)
149149
{

0 commit comments

Comments
 (0)