Skip to content

Commit

Permalink
Add archive override for RegexOutputFile
Browse files Browse the repository at this point in the history
  • Loading branch information
mnadareski committed Aug 24, 2024
1 parent ba24a4b commit cba8daa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion MPF.Processors/OutputFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public virtual bool Exists(string baseDirectory)
/// 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)
Expand Down
27 changes: 27 additions & 0 deletions MPF.Processors/RegexOutputFile.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -59,5 +62,29 @@ public override bool Exists(string baseDirectory)

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

0 comments on commit cba8daa

Please sign in to comment.