Add archive override for RegexOutputFile

This commit is contained in:
Matt Nadareski
2024-08-23 21:08:43 -04:00
parent ba24a4b21a
commit cba8daa010
3 changed files with 29 additions and 1 deletions

View File

@@ -56,6 +56,7 @@
- Rename new method to CheckRequiredFiles
- Use simplified CheckAllOutputFilesExist
- Create and use RegexOutputFile
- Add archive override for RegexOutputFile
### 3.2.1 (2024-08-05)

View File

@@ -233,7 +233,7 @@ namespace MPF.Processors
/// Indicates if an output file exists in an archive
/// </summary>
/// <param name="archive">Zip archive to check in</param>
public bool Exists(ZipArchive? archive)
public virtual bool Exists(ZipArchive? archive)
{
// If the archive is invalid
if (archive == null)

View File

@@ -1,5 +1,8 @@
using System;
using System.IO;
#if NET452_OR_GREATER || NETCOREAPP
using System.IO.Compression;
#endif
using System.Linq;
using System.Text.RegularExpressions;
@@ -59,5 +62,29 @@ namespace MPF.Processors
return false;
}
#if NET452_OR_GREATER || NETCOREAPP
/// <summary>
/// Indicates if an output file exists in an archive
/// </summary>
/// <param name="archive">Zip archive to check in</param>
public override bool Exists(ZipArchive? archive)
{
// If the archive is invalid
if (archive == null)
return false;
// Get list of all files in archive
var archiveFiles = archive.Entries.Select(e => e.Name).ToList();
foreach (string file in archiveFiles)
{
if (Filenames.Any(pattern => Regex.IsMatch(file, pattern)))
return true;
}
return false;
}
#endif
}
}