Skip to content

Commit

Permalink
[Fixed] Last file didn't have enough zeroes
Browse files Browse the repository at this point in the history
  • Loading branch information
SlowpokeVG committed Mar 25, 2019
1 parent 6ed1cb3 commit f8cb460
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions PARC Archive Importer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public partial class Form1 : Form

public static void AppendAllBytes(string path, byte[] bytes)
{
//argument-checking here.

using (var stream = new FileStream(path, FileMode.Append))
{
stream.Write(bytes, 0, bytes.Length);
Expand Down Expand Up @@ -70,7 +68,6 @@ static int ParseOffset(byte[] input, int adr)
}
static byte[] ReturnToSender(string Hex)
{
//string Hex = dec.ToString("X");
string Hex4 = null;
if (Hex.Length % 2 == 1)
{
Expand Down Expand Up @@ -119,7 +116,7 @@ void ChngInArray(int howmany, int address, byte[] from, byte[] where)
int Foldercount;
int Filestartoffset;
int Folderstartoffset;
//int DifferenceAfterInj;

public string[] folderlist;
public string namecurrentimport;
public Form1()
Expand All @@ -139,7 +136,7 @@ void ParseSourceArray(byte[] OrigArchive)
Foldercount = ParseOffset(OrigArchive, 16);
Filestartoffset = ParseOffset(OrigArchive, 28);
Folderstartoffset = ParseOffset(OrigArchive, 20);
//DifferenceAfterInj = 0;

List<string> filelist = new List<string>();
filelist.Clear();
string[] foldernames = new string[Filecount];
Expand Down Expand Up @@ -184,7 +181,7 @@ void ParseSourceArray(byte[] OrigArchive)
bool iswide()
{
bool isitwide = true;
for (int i = 0; i < listArch.Items.Count - 2; i++)
for (int i = 0; i < listArch.Items.Count - 1; i++)
{
if ((int.Parse(listArch.Items[i + 1].SubItems[2].Text) - int.Parse(listArch.Items[i].SubItems[2].Text)) % 2048 != 0)
{
Expand Down Expand Up @@ -251,7 +248,7 @@ private void buttonWiden_Click(object sender, EventArgs e)
listArch.Enabled = false;
listArch.Visible = false;
int totaldifference = 0;
for (int i = 0; i < listArch.Items.Count - 2; i++)
for (int i = 0; i < listArch.Items.Count - 1; i++)
{
int originalfilesize = int.Parse(listArch.Items[i + 1].SubItems[2].Text) - int.Parse(listArch.Items[i].SubItems[2].Text);
if (originalfilesize % 2048 != 0)
Expand Down Expand Up @@ -334,14 +331,11 @@ private void buttonSave_Click(object sender, EventArgs e)
}

}
else if (m == listViewdebug.Items.Count - 1)
else
{

byte[] zeroes = new byte[(int.Parse(listArch.Items[m].SubItems[3].Text) / 2048 + 1) * 2048 - int.Parse(listArch.Items[m].SubItems[3].Text)];
byte[] zeroes = new byte[(int.Parse(listArch.Items[m].SubItems[4].Text) / 2048 + 1) * 2048 - int.Parse(listArch.Items[m].SubItems[4].Text)];
fcreate.Write(zeroes, 0, zeroes.Length);
}


}

fcreate.Flush();
Expand Down Expand Up @@ -500,5 +494,6 @@ private void buttonInject_Click(object sender, EventArgs e)
listArch.Visible = true;

}

}
}

0 comments on commit f8cb460

Please sign in to comment.