Skip to content

Commit

Permalink
Added QOL Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vaishnav67 committed Sep 27, 2021
1 parent 1527349 commit b9200a7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pxl2ipa/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ namespace pxl2ipa
{
public partial class Form1 : Form
{
public static string ReplaceLastOccurrence(string Source, string Find, string Replace)
{
int place = Source.LastIndexOf(Find);

if (place == -1)
return Source;

string result = Source.Remove(place, Find.Length).Insert(place, Replace);
return result;
}
public Form1()
{
InitializeComponent();
Expand All @@ -23,6 +33,7 @@ private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
textBox1.Text = openFileDialog1.FileName;
textBox2.Text = ReplaceLastOccurrence(openFileDialog1.SafeFileName,".pxl",".ipa");
}

private void button2_Click(object sender, EventArgs e)
Expand All @@ -33,13 +44,19 @@ private void button2_Click(object sender, EventArgs e)

private void button3_Click(object sender, EventArgs e)
{
if(File.Exists(textBox2.Text))
{
MessageBox.Show("IPA already exists!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
Directory.CreateDirectory(".\\PXL2IPATEMP");
ZipFile.ExtractToDirectory(textBox1.Text, ".\\PXL2IPATEMP");
List<string> plist = File.ReadAllLines(".\\PXL2IPATEMP\\PxlPkg.plist").ToList();
Directory.CreateDirectory(".\\PXL2IPATEMP\\TheIpa");
Directory.CreateDirectory(".\\PXL2IPATEMP\\TheIpa\\Payload");
Directory.Move(".\\PXL2IPATEMP\\app", $".\\PXL2IPATEMP\\TheIpa\\Payload\\{textBox1.Text.Split('\\')[textBox1.Text.Split('\\').Length - 1]}.app");
ZipFile.CreateFromDirectory(".\\PXL2IPATEMP\\TheIpa", textBox2.Text);
Directory.Delete(".\\PXL2IPATEMP", true);
}
}
}

0 comments on commit b9200a7

Please sign in to comment.