private IEnumerable <string> GetItemsInternal(string filter, DirectoryEnumerator.EnumerationType enumType, Predicate <NativeMethods.WIN32_FIND_DATA> extendedFilter = null)
        {
            string itemName;

            NativeMethods.WIN32_FIND_DATA findData;
            while (this.GetNextItem(filter, enumType, out itemName, out findData, extendedFilter))
            {
                yield return(itemName);
            }
            if (this.m_recurse)
            {
                foreach (string dir in this.m_realDirectories)
                {
                    string fullPath = Path.Combine(this.m_path.FullName, dir);
                    using (DirectoryEnumerator dirEnum = new DirectoryEnumerator(new DirectoryInfo(fullPath), this.m_recurse, this.m_includeRecycleBin))
                    {
                        foreach (string item in dirEnum.GetItemsInternal(filter, enumType, extendedFilter))
                        {
                            yield return(item);
                        }
                    }
                }
            }
            yield break;
        }
 private void EnumerateFilesForDirectory(TopNList <DirectorySpaceEnumerator.DirectorySize> topDirsBySize, string dir)
 {
     MountPointUtil.HandleIOExceptions(delegate
     {
         DirectoryInfo path = new DirectoryInfo(dir);
         using (DirectoryEnumerator directoryEnumerator = new DirectoryEnumerator(path, false, false))
         {
             ulong num = 0UL;
             string text;
             NativeMethods.WIN32_FIND_DATA win32_FIND_DATA;
             while (directoryEnumerator.GetNextFileExtendedInfo("*", out text, out win32_FIND_DATA))
             {
                 ulong longFileSize = this.GetLongFileSize(win32_FIND_DATA.FileSizeLow, win32_FIND_DATA.FileSizeHigh);
                 num += longFileSize;
             }
             this.InsertIfNecessary(topDirsBySize, dir, num);
         }
     });
 }
        private IEnumerable <DirectorySpaceEnumerator.DirectorySize> GetTopNDirectories()
        {
            TopNList <DirectorySpaceEnumerator.DirectorySize> topDirsBySize = new TopNList <DirectorySpaceEnumerator.DirectorySize>(this.m_maxDirectories, Dependencies.Assert);

            MountPointUtil.HandleIOExceptions(delegate
            {
                DirectoryInfo path = new DirectoryInfo(this.m_rootDirectory);
                using (DirectoryEnumerator directoryEnumerator = new DirectoryEnumerator(path, true, true))
                {
                    Predicate <NativeMethods.WIN32_FIND_DATA> extendedFilter = (NativeMethods.WIN32_FIND_DATA findData) => (findData.FileAttributes & NativeMethods.FileAttributes.ReparsePoint) == NativeMethods.FileAttributes.None;
                    foreach (string dir in directoryEnumerator.EnumerateDirectories("*", extendedFilter))
                    {
                        this.EnumerateFilesForDirectory(topDirsBySize, dir);
                    }
                    this.EnumerateFilesForDirectory(topDirsBySize, this.m_rootDirectory);
                }
            });
            return(topDirsBySize);
        }
        public IEnumerable <string> EnumerateFiles(string filter, Predicate <NativeMethods.WIN32_FIND_DATA> extendedFilter = null)
        {
            if (!string.Equals(filter, "*"))
            {
                if (this.m_recurse)
                {
                    bool returnBaseNames = this.ReturnBaseNames;
                    try
                    {
                        this.ReturnBaseNames = false;
                        IEnumerable <string> directories = this.EnumerateDirectories("*", extendedFilter);
                        foreach (string dir in directories)
                        {
                            using (DirectoryEnumerator dirEnum = new DirectoryEnumerator(new DirectoryInfo(dir), false, this.m_includeRecycleBin))
                            {
                                dirEnum.ReturnBaseNames = returnBaseNames;
                                foreach (string item in dirEnum.GetItemsInternal(filter, DirectoryEnumerator.EnumerationType.Files, extendedFilter))
                                {
                                    yield return(item);
                                }
                            }
                        }
                    }
                    finally
                    {
                        this.ReturnBaseNames = returnBaseNames;
                    }
                    goto IL_1CD;
                }
            }
            string itemName;

            NativeMethods.WIN32_FIND_DATA findData;
            while (this.GetNextItem(filter, DirectoryEnumerator.EnumerationType.Files, out itemName, out findData, extendedFilter))
            {
                yield return(itemName);
            }
IL_1CD:
            yield break;
        }