Perform better path emptiness checks

This commit is contained in:
Matt Nadareski
2024-12-03 20:30:15 -05:00
parent c26253007d
commit 4e338d56cd
4 changed files with 11 additions and 10 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -122,10 +122,10 @@ namespace MPF.Processors
/// </summary>
/// <param name="mainInfo">_mainInfo.txt file location</param>
/// <returns>Newline-deliminated PVD if possible, null on error</returns>
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