11using System . Diagnostics . CodeAnalysis ;
2+ using Microsoft . Extensions . FileSystemGlobbing ;
3+ using Microsoft . Extensions . FileSystemGlobbing . Abstractions ;
24
35namespace ModularPipelines . FileSystem ;
46
@@ -105,11 +107,23 @@ public Folder MoveTo(string path)
105107
106108 public IEnumerable < Folder > GetFolders ( Func < Folder , bool > predicate ) => DirectoryInfo . EnumerateDirectories ( "*" , SearchOption . AllDirectories )
107109 . Select ( x => new Folder ( x ) )
110+ . Distinct ( )
108111 . Where ( predicate ) ;
109112
110113 public IEnumerable < File > GetFiles ( Func < File , bool > predicate ) => DirectoryInfo . EnumerateFiles ( "*" , SearchOption . AllDirectories )
111114 . Select ( x => new File ( x ) )
115+ . Distinct ( )
112116 . Where ( predicate ) ;
117+
118+ public IEnumerable < File > GetFiles ( string globPattern )
119+ {
120+ return new Matcher ( StringComparison . OrdinalIgnoreCase )
121+ . AddInclude ( globPattern )
122+ . Execute ( new DirectoryInfoWrapper ( DirectoryInfo ) )
123+ . Files
124+ . Select ( x => new File ( x . Path ) )
125+ . Distinct ( ) ;
126+ }
113127
114128 public File ? FindFile ( Func < File , bool > predicate ) => GetFiles ( predicate ) . FirstOrDefault ( ) ;
115129
@@ -118,13 +132,15 @@ public IEnumerable<File> GetFiles(Func<File, bool> predicate) => DirectoryInfo.E
118132 public IEnumerable < File > ListFiles ( )
119133 {
120134 return DirectoryInfo . EnumerateFiles ( "*" , SearchOption . TopDirectoryOnly )
121- . Select ( x => new File ( x ) ) ;
135+ . Select ( x => new File ( x ) )
136+ . Distinct ( ) ;
122137 }
123138
124139 public IEnumerable < Folder > ListFolders ( )
125140 {
126141 return DirectoryInfo . EnumerateDirectories ( "*" , SearchOption . TopDirectoryOnly )
127- . Select ( x => new Folder ( x ) ) ;
142+ . Select ( x => new Folder ( x ) )
143+ . Distinct ( ) ;
128144 }
129145
130146 public static Folder CreateTemporaryFolder ( )
@@ -179,6 +195,11 @@ public bool Equals(Folder? other)
179195 return true ;
180196 }
181197
198+ if ( OperatingSystem . IsWindows ( ) )
199+ {
200+ return string . Equals ( Path , other . Path , StringComparison . OrdinalIgnoreCase ) ;
201+ }
202+
182203 return Path == other . Path ;
183204 }
184205
0 commit comments