Beispiel #1
0
        public DiskAnalyzeResult Analyze(Disk disk)
        {
            _diskUsedSpaceBytes = disk.UsedSizeBytes;
            var root = new DiskItem(disk.RootPath, DiskItemKind.Directory);

            Analyze(root);
            _totalAnalyzedBytes = _diskUsedSpaceBytes;
            RaiseOnAnalyzeProgress();
            RaiseOnAnalyzeComplete();

            return(new DiskAnalyzeResult(disk, root));
        }
Beispiel #2
0
        private bool Analyze(DiskItem parent)
        {
            var directoryPaths = _fileSystem.GetDirectories(parent.FullPath);

            if (directoryPaths == null)
            {
                return(false);
            }
            if (directoryPaths.Any())
            {
                parent.Children = new List <DiskItem>(directoryPaths.Length);
            }
            foreach (var directoryPath in directoryPaths)
            {
                var directory = new DiskItem(directoryPath, DiskItemKind.Directory);
                if (Analyze(directory))
                {
                    parent.Children.Add(directory);
                    parent.SizeBytes += directory.SizeBytes;
                }
            }
            var filePaths = _fileSystem.GetFiles(parent.FullPath);

            if (filePaths == null)
            {
                return(false);
            }
            if (filePaths.Any() && parent.Children == null)
            {
                parent.Children = new List <DiskItem>(filePaths.Length);
            }
            foreach (var filePath in filePaths)
            {
                var file = new DiskItem(filePath, DiskItemKind.File);
                parent.Children.Add(file);
                file.SizeBytes       = _fileSystem.GetFileSize(filePath);
                parent.SizeBytes    += file.SizeBytes;
                _totalAnalyzedBytes += file.SizeBytes;
            }
            RaiseOnAnalyzeProgress();

            return(true);
        }
 public void GotoDirectory(DiskItem diskItem)
 {
     _historyDiskItems.Push(diskItem);
 }
Beispiel #4
0
 public DiskAnalyzeResult(Disk disk, DiskItem root)
 {
     Disk = disk;
     Root = root;
 }