From eba5a9d1897b534a212b81d92f0df0b7c274c674 Mon Sep 17 00:00:00 2001 From: Logan Lowe Date: Sun, 20 Feb 2022 17:54:17 -0700 Subject: [PATCH 1/2] Update MainForm.cs Solves #10 --- UnionPatcher.Gui/MainForm.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/UnionPatcher.Gui/MainForm.cs b/UnionPatcher.Gui/MainForm.cs index e35daa6..31cf0a4 100644 --- a/UnionPatcher.Gui/MainForm.cs +++ b/UnionPatcher.Gui/MainForm.cs @@ -10,7 +10,7 @@ namespace LBPUnion.UnionPatcher.Gui { private readonly FilePicker filePicker; private readonly TextBox serverUrl; private readonly FilePicker outputFileName; - + private Uri uriResult; public Dialog CreateOkDialog(string title, string errorMessage) { DynamicLayout layout = new(); Button button; @@ -86,6 +86,18 @@ namespace LBPUnion.UnionPatcher.Gui { return; } + if (this.filePicker.FilePath == this.outputFileName.FilePath) + { + this.CreateOkDialog("Form Error", "Input and output filename are the same! Please save the patched file with a different name so you have a backup of your the original EBOOT.ELF.").ShowModal(); + return; + } + + if (!Uri.TryCreate(this.serverUrl.Text, UriKind.Absolute, out uriResult)) + { + this.CreateOkDialog("Form Error", "Server URL is invalid! Please enter a valid URL.").ShowModal(); + return; + } + try { Patcher.PatchFile(this.filePicker.FilePath, this.serverUrl.Text, this.outputFileName.FilePath); } From 36dc7dc37e7a501e5439584ce9ae558423661f73 Mon Sep 17 00:00:00 2001 From: Logan Lowe Date: Sun, 20 Feb 2022 18:18:06 -0700 Subject: [PATCH 2/2] Review fix We don't need that Uri --- UnionPatcher.Gui/MainForm.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/UnionPatcher.Gui/MainForm.cs b/UnionPatcher.Gui/MainForm.cs index 31cf0a4..aed41a5 100644 --- a/UnionPatcher.Gui/MainForm.cs +++ b/UnionPatcher.Gui/MainForm.cs @@ -10,7 +10,6 @@ namespace LBPUnion.UnionPatcher.Gui { private readonly FilePicker filePicker; private readonly TextBox serverUrl; private readonly FilePicker outputFileName; - private Uri uriResult; public Dialog CreateOkDialog(string title, string errorMessage) { DynamicLayout layout = new(); Button button; @@ -92,7 +91,7 @@ namespace LBPUnion.UnionPatcher.Gui { return; } - if (!Uri.TryCreate(this.serverUrl.Text, UriKind.Absolute, out uriResult)) + if (!Uri.TryCreate(this.serverUrl.Text, UriKind.Absolute, out _)) { this.CreateOkDialog("Form Error", "Server URL is invalid! Please enter a valid URL.").ShowModal(); return;