diff --git a/CHANGELIST.md b/CHANGELIST.md index 9dfb228f..fdb9638d 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -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) diff --git a/MPF.Processors/OutputFile.cs b/MPF.Processors/OutputFile.cs index 68b8903d..021b5842 100644 --- a/MPF.Processors/OutputFile.cs +++ b/MPF.Processors/OutputFile.cs @@ -233,7 +233,7 @@ namespace MPF.Processors /// Indicates if an output file exists in an archive /// /// Zip archive to check in - public bool Exists(ZipArchive? archive) + public virtual bool Exists(ZipArchive? archive) { // If the archive is invalid if (archive == null) diff --git a/MPF.Processors/RegexOutputFile.cs b/MPF.Processors/RegexOutputFile.cs index 1a474c94..87df9d62 100644 --- a/MPF.Processors/RegexOutputFile.cs +++ b/MPF.Processors/RegexOutputFile.cs @@ -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 + /// + /// Indicates if an output file exists in an archive + /// + /// Zip archive to check in + 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 } } \ No newline at end of file