From b9200a7e9fb3675da9e93e5c462fed446f2b11d9 Mon Sep 17 00:00:00 2001 From: Vaishnav Santhosh Date: Mon, 27 Sep 2021 22:32:01 +0530 Subject: [PATCH] Added QOL Changes --- pxl2ipa/Form1.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pxl2ipa/Form1.cs b/pxl2ipa/Form1.cs index ad51cd3..c6fdfa7 100644 --- a/pxl2ipa/Form1.cs +++ b/pxl2ipa/Form1.cs @@ -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(); @@ -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) @@ -33,6 +44,11 @@ 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 plist = File.ReadAllLines(".\\PXL2IPATEMP\\PxlPkg.plist").ToList(); @@ -40,6 +56,7 @@ private void button3_Click(object sender, EventArgs e) 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); } } }