Nuke.Cola
Loading...
Searching...
No Matches
ISearchFiles.cs
1using EverythingSearchClient;
2using Nuke.Common;
3using Nuke.Common.IO;
4
5#pragma warning disable CA1416 // Validate platform compatibility
6
7namespace Nuke.Cola.Search;
8
9/// <summary>
10/// Simple interface for swapping file search engines
11/// </summary>
12public interface ISearchFileSystem
13{
14 IEnumerable<AbsolutePath> GlobFiles(AbsolutePath root, string pattern);
15 IEnumerable<AbsolutePath> GlobDirectories(AbsolutePath root, string pattern);
16 int Priority { get; }
17}
18
19public static class SearchFileSystem
20{
21 private static ISearchFileSystem? _current;
22
23 private static ISearchFileSystem GetGlobbing()
24 {
25 if (_current != null) return _current!;
26 if (EnvironmentInfo.IsWin && SearchClient.IsEverythingAvailable() && false)
27 {
28 _current = new EverythingGlobbing();
29 }
30 else
31 {
32 _current = new NukeGlobbing();
33 }
34 return _current;
35 }
36
37 /// <summary>
38 /// Very similar to GlobFiles but uses different engines for better performance depenging on
39 /// user's setup and platform.
40 /// </summary>
41 /// <remarks>
42 /// As of time of writing the following engines available:
43 ///
44 /// * Nuke built in Globbing
45 /// * Voidtools Everything if installed on the system
46 /// </remarks>
47 public static IEnumerable<AbsolutePath> SearchFiles(this AbsolutePath root, string pattern)
48 => GetGlobbing().GlobFiles(root, pattern);
49
50
51 /// <summary>
52 /// Very similar to GlobDirectories but uses different engines for better performance depenging on
53 /// user's setup and platform.
54 /// </summary>
55 /// <remarks>
56 /// As of time of writing the following engines available:
57 ///
58 /// * Nuke built in Globbing
59 /// * Voidtools Everything if installed on the system
60 /// </remarks>
61 public static IEnumerable<AbsolutePath> SearchDirectories(this AbsolutePath root, string pattern)
62 => GetGlobbing().GlobDirectories(root, pattern);
63}
64
66{
67 public IEnumerable<AbsolutePath> GlobFiles(AbsolutePath root, string pattern)
68 => root.GlobFiles(pattern);
69 public IEnumerable<AbsolutePath> GlobDirectories(AbsolutePath root, string pattern)
70 => root.GlobDirectories(pattern);
71
72 public int Priority => int.MaxValue;
73}
static IEnumerable< AbsolutePath > SearchFiles(this AbsolutePath root, string pattern)
Very similar to GlobFiles but uses different engines for better performance depenging on user's setup...
static IEnumerable< AbsolutePath > SearchDirectories(this AbsolutePath root, string pattern)
Very similar to GlobDirectories but uses different engines for better performance depenging on user's...
Simple interface for swapping file search engines.