mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Ensure consistency in output file path checking (fixes #755)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
- Fix trimming of header output
|
||||
- Use fake filename for Redumper DAT
|
||||
- Ensure that the full base path is being used
|
||||
- Ensure consistency in output file path checking
|
||||
|
||||
### 3.2.2 (2024-09-24)
|
||||
|
||||
|
||||
@@ -52,18 +52,9 @@ namespace MPF.Processors
|
||||
_existsFunc = existsFunc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if an output file exists in a base directory
|
||||
/// </summary>
|
||||
/// <param name="baseDirectory">Base directory to check in</param>
|
||||
public override bool Exists(string baseDirectory)
|
||||
/// <inheritdoc/>
|
||||
public override bool Exists()
|
||||
{
|
||||
// If the base directory is invalid
|
||||
if (string.IsNullOrEmpty(baseDirectory))
|
||||
return false;
|
||||
if (!Directory.Exists(baseDirectory))
|
||||
return false;
|
||||
|
||||
foreach (string filename in Filenames)
|
||||
{
|
||||
// Check for invalid filenames
|
||||
@@ -72,8 +63,7 @@ namespace MPF.Processors
|
||||
|
||||
try
|
||||
{
|
||||
string possiblePath = Path.Combine(baseDirectory, filename);
|
||||
if (_existsFunc(possiblePath))
|
||||
if (_existsFunc(filename))
|
||||
return true;
|
||||
}
|
||||
catch { }
|
||||
|
||||
@@ -192,15 +192,8 @@ namespace MPF.Processors
|
||||
/// <summary>
|
||||
/// Indicates if an output file exists in a base directory
|
||||
/// </summary>
|
||||
/// <param name="baseDirectory">Base directory to check in</param>
|
||||
public virtual bool Exists(string baseDirectory)
|
||||
public virtual bool Exists()
|
||||
{
|
||||
// If the base directory is invalid
|
||||
if (string.IsNullOrEmpty(baseDirectory))
|
||||
return false;
|
||||
if (!Directory.Exists(baseDirectory))
|
||||
return false;
|
||||
|
||||
foreach (string filename in Filenames)
|
||||
{
|
||||
// Check for invalid filenames
|
||||
@@ -209,8 +202,7 @@ namespace MPF.Processors
|
||||
|
||||
try
|
||||
{
|
||||
string possiblePath = Path.Combine(baseDirectory, filename);
|
||||
if (File.Exists(possiblePath))
|
||||
if (File.Exists(filename))
|
||||
return true;
|
||||
}
|
||||
catch { }
|
||||
|
||||
@@ -45,13 +45,10 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Exists(string baseDirectory)
|
||||
public override bool Exists()
|
||||
{
|
||||
// If the base directory is invalid
|
||||
if (string.IsNullOrEmpty(baseDirectory))
|
||||
return false;
|
||||
if (!Directory.Exists(baseDirectory))
|
||||
return false;
|
||||
// Get the base directory for the first path
|
||||
string baseDirectory = Path.GetDirectoryName(Filenames[0]) ?? string.Empty;
|
||||
|
||||
// Get list of all files in directory
|
||||
var directoryFiles = Directory.GetFiles(baseDirectory);
|
||||
|
||||
Reference in New Issue
Block a user