예제 #1
0
        private static FolderNode ScanFolder(string path, int level)
        {
            var thisNode = new FolderNode(path, showTopXFiles, showTopXSubfolders);

            string[] subDirectories;
            try
            {
                subDirectories = Directory.GetDirectories(path);
            }
            catch (Exception)
            {
                return(null); // skip <junction>
            }

            foreach (var subDirPath in subDirectories)
            {
                var folderNode = (level == 0)
                    ? LoadFromFolderCache(subDirPath, level)
                    : ScanFolder(subDirPath, level + 1);

                if (folderNode == null)
                {
                    continue;
                }

                thisNode.AddChild(folderNode);

                if (level == 0)
                {
                    if (showFinishedRootsImmediately)
                    {
                        PrintFolder(folderNode, 0);
                    }

                    SaveFolderCache(folderNode);
                }
            }

            foreach (var file in Directory.GetFiles(path))
            {
                var fNode = new FileNode(file);
                thisNode.AddItem(fNode);
            }

            return(thisNode);
        }
예제 #2
0
        private static void PrintSummaryLevelTops(FolderNode summary, int level, int maxLevel)
        {
            if (level < maxLevel)
            {
                var subFolders = summary.GetTopChildren(showTopXSubfolders);
                foreach (var subFolder in subFolders)
                {
                    PrintFolder(subFolder, level);
                    PrintSummaryLevelTops(subFolder, level + 1, maxLevel);
                }
            }

            if (showFiles)
            {
                foreach (var file in summary.GetTopFiles(showTopXSubfolders))
                {
                    PrintFile(file, level);
                }
            }
        }
예제 #3
0
        private static void PrintSummaryLevelPercentages(FolderNode parentFolder, int level, int maxLevel)
        {
            if (level < maxLevel)
            {
                var     subFolders = parentFolder.GetSortedChildren();
                decimal total      = 0.0m;
                foreach (var subFolder in subFolders)
                {
                    if (total > parentFolder.Value * showPercentage)
                    {
                        break;
                    }

                    total += subFolder.Value;

                    PrintFolderPercentage(subFolder, level, parentFolder.Value);
                    PrintSummaryLevelPercentages(subFolder, level + 1, maxLevel);
                }
            }

            if (showFiles)
            {
                decimal total = 0.0m;
                foreach (var file in parentFolder.GetSortedFiles(showTopXSubfolders))
                {
                    if (total > parentFolder.Value * showPercentage)
                    {
                        break;
                    }

                    total += file.Value;

                    PrintFilePercentage(file, level, parentFolder.Value);
                }
            }
        }
예제 #4
0
 private static void SaveFolderCache(FolderNode folder)
 {
     // Save cache for later usage
 }
예제 #5
0
 public void AddChild(FolderNode child)
 {
     this._folderCollection.Add(child);
 }