public IFileSystemInformation GetPathInfo(string path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } return(FileSystemInformation.Create(path, this)); }
internal static IEnumerable <IFileSystemInformation> EnumerateChildrenInternal( string directory, ChildType childType, string searchPattern, System.IO.SearchOption searchOption, System.IO.FileAttributes excludeAttributes, IFileService fileService) { var firstFile = NativeMethods.FileManagement.FindFirstFile(Paths.Combine(directory, searchPattern)); var findInfo = firstFile; if (firstFile != null) { // Look for specified file/directories do { bool isDirectory = findInfo.Attributes.HasFlag(System.IO.FileAttributes.Directory); if ((findInfo.Attributes & excludeAttributes) == 0 && findInfo.FileName != "." && findInfo.FileName != ".." && ((isDirectory && childType == ChildType.Directory) || (!isDirectory && childType == ChildType.File))) { yield return(FileSystemInformation.Create(findInfo, fileService)); } findInfo = NativeMethods.FileManagement.FindNextFile(firstFile); } while (findInfo != null); firstFile.FindHandle.Close(); } if (searchOption != System.IO.SearchOption.AllDirectories) { yield break; } // Need to recurse to find additional matches firstFile = NativeMethods.FileManagement.FindFirstFile(Paths.Combine(directory, "*"), directoriesOnly: true); if (firstFile == null) { yield break; } findInfo = firstFile; do { if ((findInfo.Attributes & excludeAttributes) == 0 && findInfo.Attributes.HasFlag(System.IO.FileAttributes.Directory) && findInfo.FileName != "." && findInfo.FileName != "..") { IFileSystemInformation childDirectory = DirectoryInformation.Create(findInfo, fileService); foreach (var child in EnumerateChildrenInternal(childDirectory.Path, childType, searchPattern, searchOption, excludeAttributes, fileService)) { yield return(child); } } findInfo = NativeMethods.FileManagement.FindNextFile(firstFile); } while (findInfo != null); firstFile.FindHandle.Close(); }
public IFileSystemInformation TransformResult(ref RawFindData findData) { return(FileSystemInformation.Create(ref findData, _fileService)); }