From 28f6d50e5af611d187473c8d483d6bd4e9088db0 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 30 Mar 2019 21:44:57 -0700 Subject: [PATCH] Better error checking; more DICUI.Check updates --- DICUI.Check/Program.cs | 13 ++++++------- DICUI.Library/Utilities/DumpEnvironment.cs | 12 ++++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/DICUI.Check/Program.cs b/DICUI.Check/Program.cs index 46802a08..f983143c 100644 --- a/DICUI.Check/Program.cs +++ b/DICUI.Check/Program.cs @@ -30,19 +30,18 @@ namespace DICUI.Check // Loop through all the rest of the args for (int i = 1; i < args.Length; i++) { - // Check for a directory - if (!Directory.Exists(args[i])) + // Check for a file + if (!File.Exists(args[i])) { - DisplayHelp($"{args[i]} is not a directory"); + DisplayHelp($"{args[i]} does not exist"); return; } // Now populate an environment - string procPath = args[i].TrimEnd(Path.DirectorySeparatorChar); var env = new DumpEnvironment { - OutputDirectory = procPath + Path.DirectorySeparatorChar, - OutputFilename = Path.GetFileName(procPath) + ".bin", + OutputDirectory = "", + OutputFilename = args[i], System = knownSystem, Type = mediaType, ScanForProtection = false, @@ -61,7 +60,7 @@ namespace DICUI.Check Console.WriteLine(error); Console.WriteLine("Usage:"); - Console.WriteLine("DICUI.Check.exe ..."); + Console.WriteLine("DICUI.Check.exe ..."); Console.WriteLine(); Console.WriteLine(@"Media Types:\r\n cd / cdrom - CD-ROM diff --git a/DICUI.Library/Utilities/DumpEnvironment.cs b/DICUI.Library/Utilities/DumpEnvironment.cs index 7eb0a6bc..f3e2708f 100644 --- a/DICUI.Library/Utilities/DumpEnvironment.cs +++ b/DICUI.Library/Utilities/DumpEnvironment.cs @@ -460,7 +460,15 @@ namespace DICUI.Utilities mappings[Template.AdditionalMouldField] = Template.RequiredIfExistsValue; mappings[Template.ToolstampField] = Template.RequiredIfExistsValue; mappings[Template.PVDField] = GetPVD(combinedBase + "_mainInfo.txt") ?? "Disc has no PVD"; - mappings[Template.ErrorCountField] = GetErrorCount(combinedBase + ".img_EdcEcc.txt").ToString(); + + long errorCount = -1; + if (File.Exists(combinedBase + ".img_EdcEcc.txt")) + errorCount = GetErrorCount(combinedBase + ".img_EdcEcc.txt"); + else if (File.Exists(combinedBase + ".img_EccEdc.txt")) + errorCount = GetErrorCount(combinedBase + ".img_EccEdc.txt"); + + mappings[Template.ErrorCountField] = (errorCount == -1 ? "Error retrieving error count" : errorCount.ToString()); + mappings[Template.CuesheetField] = GetFullFile(combinedBase + ".cue") ?? ""; mappings[Template.WriteOffsetField] = GetWriteOffset(combinedBase + "_disc.txt") ?? ""; @@ -1030,7 +1038,7 @@ namespace DICUI.Utilities /// /// Get the detected error count from the input files, if possible /// - /// .img_EdcEcc.txt file location + /// .img_EdcEcc.txt/.img_EccEdc.txt file location /// Error count if possible, -1 on error private long GetErrorCount(string edcecc) {