IEnumerable <VirtualNode> createListing() { //Log.Debug ("Directory listing: ", directory); //Log.Indent++; var directories = SafeDirectoryEnumerator.EnumerateDirectories(directory.Path.RealPath, "*", SearchOption.TopDirectoryOnly); foreach (string realPath in directories) { //Log.Debug ("realPath: ", realPath); VirtualNode node = directory.GetChildDirectory(PathHelper.GetFileName(realPath)); if (node != null) { yield return(node); } } var files = SafeDirectoryEnumerator.EnumerateFiles(directory.Path.RealPath, "*", SearchOption.TopDirectoryOnly); foreach (string realPath in files) { //Log.Debug ("realPath: ", realPath); VirtualNode node = directory.GetChildFile(PathHelper.GetFileName(realPath)); if (node != null) { yield return(node); } } //Log.Indent--; }
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; } }