public static FileInfo FindFile(string fileSearchPattern) { var globSearch = new GlobSearch(fileSearchPattern); var dirPath = Path.GetDirectoryName(fileSearchPattern); var dirInfo = new DirectoryInfo(dirPath); var file = dirInfo.EnumerateFiles().FirstOrDefault(f => globSearch.Matches(f.FullName)); return(file); }
public Texture2D GetTexture2D(string file) { var search = new GlobSearch(file); var texture = allTexture2Ds.FirstOrDefault(kvp => search.Matches(kvp.Key)).Value; if (texture == null) { var f = this.FileSystem.FindExistingFile(file); texture = new Texture2D(f); allTexture2Ds[f.VirtualPath] = texture; } return(texture); }
// // Summary: // Returns an enumerable collection of file information that matches a search pattern. // // Parameters: // searchPattern: // The search string to match against the names of files. This parameter can contain // a combination of valid literal path and wildcard (* and ?) characters (see Remarks), // but doesn't support regular expressions. The default pattern is "*", which returns // all files. // // Returns: // An enumerable collection of files that matches searchPattern. // // Exceptions: // T:System.ArgumentNullException: // searchPattern is null. // // T:System.IO.DirectoryNotFoundException: // The path encapsulated in the System.IO.DirectoryInfo object is invalid, (for // example, it is on an unmapped drive). // // T:System.Security.SecurityException: // The caller does not have the required permission. public IEnumerable <FileEntry> EnumerateFiles(string searchPattern) { var g = new GlobSearch(searchPattern); return(EnumerateFiles().Where(d => g.Matches(d.Name))); }
// // Summary: // Returns an enumerable collection of file system information that matches a specified // search pattern. // // Parameters: // searchPattern: // The search string to match against the names of directories. This parameter can // contain a combination of valid literal path and wildcard (* and ?) characters // (see Remarks), but doesn't support regular expressions. The default pattern is // "*", which returns all files. // // Returns: // An enumerable collection of file system information objects that matches searchPattern. // // Exceptions: // T:System.ArgumentNullException: // searchPattern is null. // // T:System.IO.DirectoryNotFoundException: // The path encapsulated in the System.IO.DirectoryInfo object is invalid (for example, // it is on an unmapped drive). // // T:System.Security.SecurityException: // The caller does not have the required permission. public IEnumerable <FileSystemEntry> EnumerateFileSystemInfos(string searchPattern) { var g = new GlobSearch(searchPattern); return(EnumerateFileSystemInfos().Where(e => g.Matches(e.Name))); }
// // Summary: // Retrieves an array of strongly typed System.IO.FileSystemInfo objects representing // the files and subdirectories that match the specified search criteria. // // Parameters: // searchPattern: // The search string to match against the names of directories and files. This parameter // can contain a combination of valid literal path and wildcard (* and ?) characters // (see Remarks), but doesn't support regular expressions. The default pattern is // "*", which returns all files. // // Returns: // An array of strongly typed FileSystemInfo objects matching the search criteria. // // Exceptions: // T:System.ArgumentException: // searchPattern contains one or more invalid characters defined by the System.IO.Path.GetInvalidPathChars // method. // // T:System.ArgumentNullException: // searchPattern is null. // // T:System.IO.DirectoryNotFoundException: // The specified path is invalid (for example, it is on an unmapped drive). // // T:System.Security.SecurityException: // The caller does not have the required permission. public FileSystemEntry[] GetFileSystemInfos(string searchPattern) { var g = new GlobSearch(searchPattern); return(fileSystemEntries.Where(e => g.Matches(e.Name)).ToArray()); }