/// <summary>Prefetch next level of subdirectories and files.</summary> /// <param name="fileFilter">Search pattern or *null* for all.</param> /// <returns>Returns *true* if more subdirectories or files available, else *false*.</returns> protected bool PregetContents(string fileFilter) { bool result; var top = stack.Peek(); if (top.Index < 0) { result = top.dirInfos.Length > 0; top = stack.Head(); } else { DirectoryInfo[] nextDirs = top.dirInfos[top.Index].GetDirectories(DirFilter); if (dirComparer != null) { Array.Sort(nextDirs, dirComparer); } stack.Enqueue(new DirNode(nextDirs, -1)); result = nextDirs.Length > 0; } if (fileFilter != null) { FileInfo[] fInfos = top.dirInfos[top.Index].GetFiles(fileFilter); if (fileComparer != null) { Array.Sort(fInfos, fileComparer); } top.FileInfos = new ReadOnlyCollection <FileInfo> (fInfos); result = result || top.FileInfos.Count > 0; } return(result); }
public T Peek() { if (QueuedStack.Count == 0) { MoveStackToQueue(); } return(QueuedStack.Peek()); }