internal override void ManageFolders(IFileSystem fileSystem) { if (Folders != null) { // helper list to be able to modify Folders property inside the loop var iterate = new List<FolderInfo>(Folders); foreach (var folder in iterate) { if (fileSystem.Exists(this, folder)) { var directoryInfos = fileSystem.GetFolders(this, folder); foreach (var directoryInfo in directoryInfos.OrderByDescending(x => x.Name)) { var newFolder = new FolderInfo { Absolute = folder.Absolute, Filter = folder.Filter, Levels = new List<LogLevel>(folder.Levels), Name = $"{folder.Name}_{directoryInfo.Name}", Path = fileSystem.CombinePath(folder.Path, directoryInfo.Name), OpeningLinePattern = folder.OpeningLinePattern }; Folders.Insert(Folders.IndexOf(folder) + 1, newFolder); } } else { Folders.Remove(folder); } } } }
public List<FileInfo> GetFiles(HostInfo host, FolderInfo directory) { var directoryInfo = GetDirectoryInfo(host, directory); if (directoryInfo.Exists) { return directoryInfo.GetFiles(directory.Filter ?? "*").ToList(); } return new List<FileInfo>(); }
public List<DirectoryInfo> GetFolders(HostInfo host, FolderInfo directory) { if (!string.IsNullOrWhiteSpace(directory.SubfolderSearchPattern)) { var directoryInfo = GetDirectoryInfo(host, directory); if (directoryInfo.Exists) { return directoryInfo.GetDirectories(directory.SubfolderSearchPattern).ToList(); } } return new List<DirectoryInfo>(); }
public FileLogSource(string fullPath, FolderInfo folderInfo) { FullPath = fullPath; OpeningLinePattern = folderInfo.OpeningLinePattern; if (folderInfo.Levels != null) { LogLevels = new Dictionary<string, Regex>(); foreach (var level in folderInfo.Levels) { LogLevels.Add(level.Name, new Regex(level.Regex, GetOptions(level))); } } }
private string GetDirectoryPath(HostInfo host, FolderInfo directory) { return directory.Absolute ? directory.Path : GetUncDirectory(host.Unc, directory.Path); }
private DirectoryInfo GetDirectoryInfo(HostInfo host, FolderInfo directory) { string directoryPath = GetDirectoryPath(host, directory); return new DirectoryInfo(directoryPath); }
public bool Exists(HostInfo host, FolderInfo directory) { return GetDirectoryInfo(host, directory).Exists; }