/// <summary> /// Initializes an instance of <see cref="WorkspaceFileSystemDirectoryWrapper" />. /// </summary> public WorkspaceFileSystemDirectoryWrapper(WorkspaceFileSystemWrapperFactory factory, DirectoryInfo directoryInfo, int depth) { _concreteDirectoryInfo = directoryInfo; _isParentPath = (depth == 0); _fsWrapperFactory = factory; _depth = depth; }
/// <summary> /// Enumerate all the PowerShell (ps1, psm1, psd1) files in the workspace in a recursive manner. /// </summary> /// <returns>An enumerator over the PowerShell files found in the workspace.</returns> public IEnumerable <string> EnumeratePSFiles( string[] excludeGlobs, string[] includeGlobs, int maxDepth, bool ignoreReparsePoints ) { if (WorkspacePath == null || !Directory.Exists(WorkspacePath)) { yield break; } var matcher = new Microsoft.Extensions.FileSystemGlobbing.Matcher(); foreach (string pattern in includeGlobs) { matcher.AddInclude(pattern); } foreach (string pattern in excludeGlobs) { matcher.AddExclude(pattern); } var fsFactory = new WorkspaceFileSystemWrapperFactory( WorkspacePath, maxDepth, Utils.IsNetCore ? s_psFileExtensionsCoreFramework : s_psFileExtensionsFullFramework, ignoreReparsePoints, logger ); var fileMatchResult = matcher.Execute(fsFactory.RootDirectory); foreach (FilePatternMatch item in fileMatchResult.Files) { yield return(Path.Combine(WorkspacePath, item.Path)); } }
/// <summary> /// Initializes instance of <see cref="FileInfoWrapper" /> to wrap the specified object <see cref="System.IO.FileInfo" />. /// </summary> public WorkspaceFileSystemFileInfoWrapper(WorkspaceFileSystemWrapperFactory factory, FileInfo fileInfo, int depth) { _fsWrapperFactory = factory; _concreteFileInfo = fileInfo; _depth = depth; }