mirror of
https://github.com/SabreTools/MPF.git
synced 2026-05-06 20:43:47 +00:00
Add archive override for RegexOutputFile
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user