22using System . Collections . Generic ;
33using System . IO ;
44using System . Linq ;
5+ using System . Text . RegularExpressions ;
56
67namespace CASCExplorer
78{
@@ -41,8 +42,10 @@ public ICASCEntry GetEntry(string name)
4142 return entry ;
4243 }
4344
44- public static IEnumerable < CASCFile > GetFiles ( IEnumerable < ICASCEntry > entries , IEnumerable < int > selection = null , bool recursive = true )
45+ public static IEnumerable < CASCFile > GetFiles ( IEnumerable < ICASCEntry > entries , IEnumerable < int > selection = null , bool recursive = true , string filter = "" )
4546 {
47+ var wildcard = filter != string . Empty && filter != "*" ? new Wildcard ( filter , false , RegexOptions . IgnoreCase ) : null ;
48+
4649 if ( selection != null )
4750 {
4851 foreach ( int index in selection )
@@ -51,6 +54,8 @@ public static IEnumerable<CASCFile> GetFiles(IEnumerable<ICASCEntry> entries, IE
5154
5255 if ( entry is CASCFile )
5356 {
57+ if ( wildcard != null && ! wildcard . IsMatch ( entry . Name ) )
58+ continue ;
5459 yield return entry as CASCFile ;
5560 }
5661 else
@@ -59,8 +64,10 @@ public static IEnumerable<CASCFile> GetFiles(IEnumerable<ICASCEntry> entries, IE
5964 {
6065 var folder = entry as CASCFolder ;
6166
62- foreach ( var file in GetFiles ( folder . Entries . Select ( kv => kv . Value ) ) )
67+ foreach ( var file in GetFiles ( folder . Entries . Select ( kv => kv . Value ) , filter : filter ) )
6368 {
69+ if ( wildcard != null && ! wildcard . IsMatch ( file . Name ) )
70+ continue ;
6471 yield return file ;
6572 }
6673 }
@@ -73,6 +80,8 @@ public static IEnumerable<CASCFile> GetFiles(IEnumerable<ICASCEntry> entries, IE
7380 {
7481 if ( entry is CASCFile )
7582 {
83+ if ( wildcard != null && ! wildcard . IsMatch ( entry . Name ) )
84+ continue ;
7685 yield return entry as CASCFile ;
7786 }
7887 else
@@ -81,8 +90,10 @@ public static IEnumerable<CASCFile> GetFiles(IEnumerable<ICASCEntry> entries, IE
8190 {
8291 var folder = entry as CASCFolder ;
8392
84- foreach ( var file in GetFiles ( folder . Entries . Select ( kv => kv . Value ) ) )
93+ foreach ( var file in GetFiles ( folder . Entries . Select ( kv => kv . Value ) , filter : filter ) )
8594 {
95+ if ( wildcard != null && ! wildcard . IsMatch ( file . Name ) )
96+ continue ;
8697 yield return file ;
8798 }
8899 }
0 commit comments