From 533369d388a10fa2af124b1265d40d06410d3ae8 Mon Sep 17 00:00:00 2001 From: AndreasOlvebo-Frends <150336570+AndreasOlvebo-Frends@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:15:54 +0200 Subject: [PATCH] Enhance Files.Delete task to support multiple patterns with '|' separator - Updated FindMatchingFiles method to handle multiple patterns by splitting on the '|' character and adding each pattern separately to the Matcher. - Ensured correct handling of file deletion when multiple patterns are provided. --- Frends.Files.Delete/Frends.Files.Delete/Delete.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Frends.Files.Delete/Frends.Files.Delete/Delete.cs b/Frends.Files.Delete/Frends.Files.Delete/Delete.cs index 8db1119..a487b61 100644 --- a/Frends.Files.Delete/Frends.Files.Delete/Delete.cs +++ b/Frends.Files.Delete/Frends.Files.Delete/Delete.cs @@ -130,7 +130,15 @@ internal static PatternMatchingResult FindMatchingFiles(string directoryPath, st throw new DirectoryNotFoundException($"Directory does not exist or you do not have read access. Tried to access directory '{directoryPath}'"); var matcher = new Matcher(); - matcher.AddInclude(pattern); + + var patterns = pattern.Split('|', StringSplitOptions.RemoveEmptyEntries); + + // Add each pattern separately to the matcher + foreach (var individualPattern in patterns) + { + matcher.AddInclude(individualPattern.Trim()); + } + var results = matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(directoryPath))); return results; } @@ -139,4 +147,4 @@ private static void OnPluginUnloadingRequested(AssemblyLoadContext obj) { obj.Unloading -= OnPluginUnloadingRequested; } -} \ No newline at end of file +}