private IEnumerable <string>?JustCheckExtensions(string[] fileNames) { // Warning: pretty duplicated code // Result must be ordered by PATHEXT order of precedence. // Porting note: allow files with executable bit on non-Windows platforms Collection <string>?result = null; foreach (var allowedExt in _orderedPathExt) { foreach (var fileName in fileNames) { if (fileName.EndsWith(allowedExt, StringComparison.OrdinalIgnoreCase) || (!Platform.IsWindows && Platform.NonWindowsIsExecutable(fileName))) { if (result == null) { result = new Collection <string>(); } result.Add(fileName); } } } return(result); }
private IEnumerable <string>?CheckAgainstAcceptableCommandNames(string[] fileNames) { var baseNames = fileNames.Select(Path.GetFileName).ToArray(); // Result must be ordered by PATHEXT order of precedence. // acceptableCommandNames is in this order, so // Porting note: allow files with executable bit on non-Windows platforms Collection <string>?result = null; if (baseNames.Length > 0 && _acceptableCommandNames != null) { foreach (var name in _acceptableCommandNames) { for (int i = 0; i < baseNames.Length; i++) { if (name.Equals(baseNames[i], StringComparison.OrdinalIgnoreCase) || (!Platform.IsWindows && Platform.NonWindowsIsExecutable(name))) { if (result == null) { result = new Collection <string>(); } result.Add(fileNames[i]); break; } } } } return(result); }