diff --git a/CHANGELIST.md b/CHANGELIST.md index 84baa3f7..7f41b15e 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -12,6 +12,7 @@ - Fix CleanRip test access - Add tests around XBC helpers - Fix failing XBC test +- Perform better path emptiness checks ### 3.2.4 (2024-11-24) diff --git a/MPF.Processors/Aaru.cs b/MPF.Processors/Aaru.cs index ab863491..737e43bb 100644 --- a/MPF.Processors/Aaru.cs +++ b/MPF.Processors/Aaru.cs @@ -821,7 +821,7 @@ namespace MPF.Processors private static CICMMetadataType? GenerateSidecar(string cicmSidecar) { // If the file doesn't exist, we can't get info from it - if (!File.Exists(cicmSidecar)) + if (string.IsNullOrEmpty(cicmSidecar) || !File.Exists(cicmSidecar)) return null; // Open and read in the XML file @@ -933,7 +933,7 @@ namespace MPF.Processors private static long GetErrorCount(string resume) { // If the file doesn't exist, we can't get info from it - if (!File.Exists(resume)) + if (string.IsNullOrEmpty(resume) || !File.Exists(resume)) return -1; // Get a total error count for after diff --git a/MPF.Processors/CleanRip.cs b/MPF.Processors/CleanRip.cs index ec8a793c..558b8bc5 100644 --- a/MPF.Processors/CleanRip.cs +++ b/MPF.Processors/CleanRip.cs @@ -103,7 +103,7 @@ namespace MPF.Processors internal static Datafile? GenerateCleanripDatafile(string iso, string dumpinfo) { // Get the size from the ISO, if possible - long size = iso.Length > 0 && File.Exists(iso) + long size = !string.IsNullOrEmpty(iso) && File.Exists(iso) ? new FileInfo(iso).Length : -1; @@ -115,7 +115,7 @@ namespace MPF.Processors try { // Make sure this file is a dumpinfo - if (dumpinfo.Length > 0 && File.Exists(dumpinfo)) + if (!string.IsNullOrEmpty(dumpinfo) && File.Exists(dumpinfo)) { using var sr = File.OpenText(dumpinfo); if (sr.ReadLine()?.Contains("--File Generated by CleanRip") != true) @@ -172,7 +172,7 @@ namespace MPF.Processors internal static string? GetBCA(string bcaPath) { // If the file doesn't exist, we can't get the info - if (!File.Exists(bcaPath)) + if (string.IsNullOrEmpty(bcaPath) || !File.Exists(bcaPath)) return null; try @@ -215,7 +215,7 @@ namespace MPF.Processors region = null; version = null; name = null; serial = null; // If the file doesn't exist, we can't get info from it - if (!File.Exists(dumpinfo)) + if (string.IsNullOrEmpty(dumpinfo) || !File.Exists(dumpinfo)) return false; try diff --git a/MPF.Processors/UmdImageCreator.cs b/MPF.Processors/UmdImageCreator.cs index 9cd8d521..360e9b2e 100644 --- a/MPF.Processors/UmdImageCreator.cs +++ b/MPF.Processors/UmdImageCreator.cs @@ -122,10 +122,10 @@ namespace MPF.Processors /// /// _mainInfo.txt file location /// Newline-deliminated PVD if possible, null on error - private static string? GetPVD(string mainInfo) + internal static string? GetPVD(string mainInfo) { // If the file doesn't exist, we can't get info from it - if (!File.Exists(mainInfo)) + if (string.IsNullOrEmpty(mainInfo) || !File.Exists(mainInfo)) return null; try @@ -138,7 +138,7 @@ namespace MPF.Processors while (sr.ReadLine()?.StartsWith("0310") == false) ; // Now that we're at the PVD, read each line in and concatenate - string pvd = ""; + string pvd = string.Empty; for (int i = 0; i < 6; i++) pvd += sr.ReadLine() + "\n"; // 320-370 @@ -169,7 +169,7 @@ namespace MPF.Processors size = -1; // If the file doesn't exist, we can't get info from it - if (!File.Exists(disc)) + if (string.IsNullOrEmpty(disc) || !File.Exists(disc)) return false; try