public override ICommand GetCommand(string commandName) { try { NativeExecutable exe = PathIndex.GetCommand(commandName) ?? (FileHelper.Instance.IsFile(commandName) ? new NativeExecutable(commandName) : null); return(exe != null ? new NativeExecutableCommand(executable: exe) : null); } catch (Exception ex) { Log.Warning(ex); return(null); } }
void IndexExecutables() { if (!IsIndexed) { lock (lockIndex) { Log.Debug("IndexExecutables:"); Log.Indent++; foreach (string directory in PathDirectories) { Log.Debug("PathDirectory: ", directory); Log.Indent++; try { IEnumerable <string> files = SafeDirectoryEnumerator.EnumerateFiles(directory, "*", System.IO.SearchOption.TopDirectoryOnly); foreach (string fullPath in files) { if (ExecutablePathValidator.IsValidExecutable(fullPath: fullPath)) { NativeExecutable executable = new NativeExecutable(fullPath: fullPath); Log.Debug("executable: ", executable); foreach (string commandName in executable.CommandNames) { if (!PathExecutables.ContainsKey(commandName)) { PathExecutables [commandName] = executable; } } } } } catch (Exception ex) { Log.Error(ex); } Log.Indent--; } Log.Indent--; } IsIndexed = true; } }
public NativeExecutableCommand(NativeExecutable executable) { Executable = executable; ExecutableName = executable.FileName; }