public static bool Match(string value, string pattern) { int start = -1; int end = -1; return(Wildcard.Match(value, pattern, ref start, ref end)); }
private List <FindFileResult> FindFilesInSolution(FileFinder.Job job, AsyncTask.Context context) { FileFinder.SolutionFiles solution_files = null; object @lock = this.m_Lock; lock (@lock) { solution_files = this.m_SolutionFiles; } string pattern = job.m_TextBoxValue; if (!this.m_Settings.GetSolutionFilesMatchCase(job.m_IsModal)) { pattern = pattern.ToLower(); } SettingsDialogPage arg_5D_0 = VSAnythingPackage.Inst.GetSettingsDialogPage(); bool match_case = job.m_MatchCase; if (arg_5D_0.SpacesAsWildcardsForFindFile && pattern.Contains(' ')) { pattern = "*" + pattern.Replace(' ', '*') + "*"; } bool use_wildacrd = job.m_UseWildcards && pattern.Contains('*'); if (use_wildacrd) { if (!pattern.StartsWith("*")) { pattern = "*" + pattern; } if (!pattern.EndsWith("*")) { pattern += "*"; } } bool use_full_paths = pattern.Contains("\\"); IEnumerable <string> arg_121_0 = this.m_Settings.GetSolutionFilesMatchCase(job.m_IsModal) ? (use_full_paths ? solution_files.m_SolutionFilePaths : solution_files.m_SolutionFileNames) : (use_full_paths ? solution_files.m_SolutionFilePathsLowerCase : solution_files.m_SolutionFileNamesLowercase); List <FindFileResult> found_files = new List <FindFileResult>(); int i = 0; foreach (string file in arg_121_0) { bool match; if (use_wildacrd) { match = Wildcard.Match(file, pattern); } else if (match_case) { match = file.Contains(pattern); } else { match = Utils.StrStr(file, pattern); } if (match) { string file_path = solution_files.m_SolutionFilePaths[i]; string file_name = solution_files.m_SolutionFileNames[i]; FindFileResult found_file = default(FindFileResult); found_file.m_FilePath = file_path; found_file.m_FileName = file_name; if (Path.IsPathRooted(job.m_RootPath) && Path.IsPathRooted(file_path) && Path.GetPathRoot(job.m_RootPath) == Path.GetPathRoot(file_path) && !Utils.IsSolutionFile(file_path)) { found_file.m_RelativeFilePath = Misc.GetRelativePath(job.m_RootPath, file_path); } else { found_file.m_RelativeFilePath = file_path; } found_file.m_PathMatch = false; found_files.Add(found_file); } i++; if (context.Cancelled) { break; } } return(found_files); }
private List <FindFileResult> FindFilesInPath(FileFinder.Job job, AsyncTask.Context context) { List <FindFileResult> found_files = new List <FindFileResult>(); string path = job.m_TextBoxValue; string dir; try { dir = Path.GetDirectoryName(path); } catch (Exception arg_16_0) { Log.WriteLine(arg_16_0.Message); dir = path; } if (!Directory.Exists(dir)) { dir = Path.GetDirectoryName(dir); } if (!Directory.Exists(dir)) { return(found_files); } List <string> items = new List <string>(); if (!context.Cancelled) { string[] array = Directory.GetDirectories(dir); for (int i = 0; i < array.Length; i++) { string child_dir = array[i]; items.Add(Path.GetFileName(child_dir)); if (context.Cancelled) { break; } } } if (!context.Cancelled) { string[] array = Directory.GetFiles(dir); for (int i = 0; i < array.Length; i++) { string file = array[i]; items.Add(Path.GetFileName(file)); if (context.Cancelled) { break; } } } string pattern = Path.GetFileName(path).Trim().ToLower(); if (!string.IsNullOrEmpty(pattern)) { bool use_wildcard = job.m_UseWildcards && pattern.Contains('*'); List <string> filtered_items = new List <string>(); foreach (string item in items) { bool match; if (use_wildcard) { match = Wildcard.Match(item.ToLower(), pattern); } else { match = Utils.StrStr(item.ToLower(), pattern); } if (match) { filtered_items.Add(item); } if (context.Cancelled) { break; } } items = filtered_items; } if (!context.Cancelled) { foreach (string item2 in items) { found_files.Add(new FindFileResult { m_FileName = item2, m_PathMatch = true }); } } return(found_files); }