namespace View_by_Distance.Shared.Models.Stateless.Methods; internal abstract class FileHolder { internal static List GetFileHolders((string, string[])[] collection) { List results = []; foreach ((string _, string[] files) in collection) results.AddRange(files.Select(l => IFileHolder.Get(l))); return results; } internal static IEnumerable GetFileHolders(IEnumerable<(string, string)> collection) { foreach ((string _, string file) in collection) yield return IFileHolder.Get(file); } internal static IEnumerable<(string, string[])> GetFiles(string root, string searchPattern) { Stack pending = new(); pending.Push(root); while (pending.Count != 0) { string[]? next = null; string path = pending.Pop(); try { next = Directory.GetFiles(path, searchPattern); } catch { } if (next is not null && next.Length > 0) yield return new(path, next); try { next = Directory.GetDirectories(path); foreach (string subDirectory in next) pending.Push(subDirectory); } catch { } } } }