From 8b82ec3d4eaf3b4bde916de351c7ad63a8271886 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Mon, 4 Dec 2023 23:45:04 +1300 Subject: [PATCH] Catch filenotfound errors for non-PS3 ISOs --- IRDKit/Program.cs | 70 +++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs index 2866d53..9f02d64 100644 --- a/IRDKit/Program.cs +++ b/IRDKit/Program.cs @@ -302,53 +302,51 @@ namespace IRDKit } // Write PS3_DISC.SFB info - using (DiscUtils.Streams.SparseStream s = reader.OpenFile("PS3_DISC.SFB", FileMode.Open, FileAccess.Read)) + try { - try + using DiscUtils.Streams.SparseStream s = reader.OpenFile("PS3_DISC.SFB", FileMode.Open, FileAccess.Read); + PS3_DiscSFB ps3_DiscSFB = new(s); + if (json) { - PS3_DiscSFB ps3_DiscSFB = new(s); - if (json) - { - if (outPath != null) - File.AppendAllText(outPath, "\"PS3_DISC.SFB\": "); - else - Console.Write("\"PS3_DISC.SFB\": "); - ps3_DiscSFB.PrintJson(outPath); - if (outPath != null) - File.AppendAllText(outPath, ",\n"); - else - Console.WriteLine(','); - } + if (outPath != null) + File.AppendAllText(outPath, "\"PS3_DISC.SFB\": "); else - ps3_DiscSFB.Print(outPath); - } - catch - { - Console.WriteLine("PS3_DISC.SFB not found"); + Console.Write("\"PS3_DISC.SFB\": "); + ps3_DiscSFB.PrintJson(outPath); + if (outPath != null) + File.AppendAllText(outPath, ",\n"); + else + Console.WriteLine(','); } + else + ps3_DiscSFB.Print(outPath); + } + catch (FileNotFoundException) + { + if (!json) + Console.WriteLine("PS3_DISC.SFB not found. Not a valid PS3 ISO?"); } // Write PARAM.SFO info - using (DiscUtils.Streams.SparseStream s = reader.OpenFile("PS3_GAME\\PARAM.SFO", FileMode.Open, FileAccess.Read)) + try { - try + using DiscUtils.Streams.SparseStream s = reader.OpenFile("PS3_GAME\\PARAM.SFO", FileMode.Open, FileAccess.Read); + ParamSFO paramSFO = new(s); + if (json) { - ParamSFO paramSFO = new(s); - if (json) - { - if (outPath != null) - File.AppendAllText(outPath, "\"PARAM.SFO\": "); - else - Console.Write("\"PARAM.SFO\": "); - paramSFO.PrintJson(outPath); - } + if (outPath != null) + File.AppendAllText(outPath, "\"PARAM.SFO\": "); else - paramSFO.Print(outPath); - } - catch - { - Console.WriteLine("PS3_GAME\\PARAM.SFO not found"); + Console.Write("\"PARAM.SFO\": "); + paramSFO.PrintJson(outPath); } + else + paramSFO.Print(outPath); + } + catch (FileNotFoundException) + { + if (!json) + Console.WriteLine("PS3_GAME\\PARAM.SFO not found. Not a valid PS3 ISO?"); } // End JSON object