// add MRU history, suggestions, and clipboard contents to the list of examples. public static IEnumerable <string> GetInputSuggestions(string currentSuggestion, bool useClipboard, bool mustBeDirectory, string[] more) { List <string> suggestions = new List <string>(); if (!string.IsNullOrEmpty(currentSuggestion)) { suggestions.Add(currentSuggestion); } if (useClipboard && !string.IsNullOrEmpty(Utils.GetClipboard()) && Utils.LooksLikePath(Utils.GetClipboard()) == mustBeDirectory) { // get from clipboard if the right type of string (path vs not path) suggestions.Add(Utils.GetClipboard()); } if (more != null) { suggestions.AddRange(more); } return(suggestions.Where(entry => !mustBeDirectory || FilenameUtils.IsPathRooted(entry))); }
public static List <string> FindSimilarNames(string path, string[] types, string[] otherFiles, out bool nameHasSuffix, out string pathWithoutSuffix) { // parse the file pathWithoutSuffix = null; nameHasSuffix = FindPathWithSuffixRemoved(path, types, out pathWithoutSuffix); // delete all the rest in group var nameWithoutSuffix = nameHasSuffix ? pathWithoutSuffix : path; List <string> results = new List <string>(); foreach (var otherFile in otherFiles) { if (otherFile.ToUpperInvariant() != path.ToUpperInvariant()) { if (FilenameUtils.SameExceptExtension(nameWithoutSuffix, otherFile) || (FindPathWithSuffixRemoved(otherFile, types, out string nameMiddleRemoved) && FilenameUtils.SameExceptExtension(nameWithoutSuffix, nameMiddleRemoved))) { results.Add(otherFile); } } } return(results); }
public string[] GetList(bool forceRefresh = false, bool includeMarked = false) { Func <string, bool> includeFile = (path) => { if (!includeMarked && _excludeMarked && path.Contains(FilenameUtils.MarkerString)) { return(false); } else if (!FilenameUtils.IsExtensionInList(path, _extensionsAllowed)) { return(false); } else { return(true); } }; return(_list.GetList(forceRefresh).Where(includeFile).ToArray()); }