Exemplo n.º 1
0
        public override IEnumerable <EntityRecord> ListFilesFolders()
        {
            // Just use a TreeTraverser here
            TreeTraverser treeTraverser = new TreeTraverser(this.Dest);

            foreach (TreeTraverser.FolderEntry folder in treeTraverser.ListFolders())
            {
                yield return(new EntityRecord(folder.RelPath, Entity.Folder));

                foreach (TreeTraverser.FileEntry file in folder.GetFiles())
                {
                    yield return(new EntityRecord(file.RelPath, Entity.File));
                }
            }
        }
Exemplo n.º 2
0
        public override void PurgeFiles(IEnumerable <string> filesIn, IEnumerable <string> foldersIn, PurgeProgressHandler handler = null)
        {
            HashSet <string> files   = new HashSet <string>(filesIn);
            HashSet <string> folders = new HashSet <string>(foldersIn);
            // Just use a TreeTraverser here
            TreeTraverser treeTraverser = new TreeTraverser(this.Dest);

            foreach (TreeTraverser.FolderEntry folder in treeTraverser.ListFolders())
            {
                try {
                    if (folders.Contains(folder.RelPath))
                    {
                        if (handler != null && !handler(Entity.Folder, folder.RelPath, false))
                        {
                            return;
                        }
                        foreach (TreeTraverser.FileEntry file in folder.GetFiles())
                        {
                            if (!files.Contains(file.RelPath))
                            {
                                File.Delete(file.FullPath);
                                if (handler != null && !handler(Entity.File, file.RelPath, true))
                                {
                                    return;
                                }
                            }
                            else
                            {
                                if (handler != null && !handler(Entity.File, file.RelPath, false))
                                {
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        Directory.Delete(folder.FullPath);
                        if (handler != null && !handler(Entity.Folder, folder.RelPath, true))
                        {
                            return;
                        }
                    }
                }
                // Don't yet have a way of logging from in here
                catch (BackupOperationException) { }
            }
        }
Exemplo n.º 3
0
 public void Populate(string startDir, string ignoreRules) {
     // Get rid of anything there before
     this.tree.Nodes.Clear();
     // aaand start again!
     TreeTraverser treeTraverser = new TreeTraverser(startDir, ignoreRules);
     TreeNodeTri node;
     TreeTraverser.FolderEntry root = treeTraverser.ListFolders(0).First();
     foreach (TreeTraverser.FolderEntry folder in root.GetFolders()) {
         node = new TreeNodeTri(folder, this.tree.ImageList, this.IgnoredFiles, this.IgnoredFolders, this.tree);
         node.Populate();
         this.tree.Nodes.Add(node);
     }
     foreach (TreeTraverser.FileEntry file in root.GetFiles()) {
         this.tree.Nodes.Add(new TreeNodeTri(file, this.tree.ImageList, this.IgnoredFiles, this.IgnoredFolders, this.tree));
     }
 }
Exemplo n.º 4
0
        public void Populate(string startDir, string ignoreRules)
        {
            // Get rid of anything there before
            this.tree.Nodes.Clear();
            // aaand start again!
            TreeTraverser treeTraverser = new TreeTraverser(startDir, ignoreRules);
            TreeNodeTri   node;

            TreeTraverser.FolderEntry root = treeTraverser.ListFolders(0).First();
            foreach (TreeTraverser.FolderEntry folder in root.GetFolders())
            {
                node = new TreeNodeTri(folder, this.tree.ImageList, this.IgnoredFiles, this.IgnoredFolders, this.tree);
                node.Populate();
                this.tree.Nodes.Add(node);
            }
            foreach (TreeTraverser.FileEntry file in root.GetFiles())
            {
                this.tree.Nodes.Add(new TreeNodeTri(file, this.tree.ImageList, this.IgnoredFiles, this.IgnoredFolders, this.tree));
            }
        }
Exemplo n.º 5
0
        public override void PurgeFiles(IEnumerable<string> filesIn, IEnumerable<string> foldersIn, PurgeProgressHandler handler=null) {
            HashSet<string> files = new HashSet<string>(filesIn);
            HashSet<string> folders = new HashSet<string>(foldersIn);
            // Just use a TreeTraverser here
            TreeTraverser treeTraverser = new TreeTraverser(this.Dest);

            foreach (TreeTraverser.FolderEntry folder in treeTraverser.ListFolders()) {
                try {
                    if (folders.Contains(folder.RelPath)) {
                        if (handler != null && !handler(Entity.Folder, folder.RelPath, false))
                            return;
                        foreach (TreeTraverser.FileEntry file in folder.GetFiles()) {
                            if (!files.Contains(file.RelPath)) {
                                File.Delete(file.FullPath);
                                if (handler != null && !handler(Entity.File, file.RelPath, true))
                                    return;
                            }
                            else {
                                if (handler != null && !handler(Entity.File, file.RelPath, false))
                                    return;
                            }
                        }
                    }
                    else {
                        Directory.Delete(folder.FullPath);
                        if (handler != null && !handler(Entity.Folder, folder.RelPath, true))
                            return;
                    }
                }
                // Don't yet have a way of logging from in here
                catch (BackupOperationException) { }
            }
        }
Exemplo n.º 6
0
        public override IEnumerable<EntityRecord> ListFilesFolders() {
            // Just use a TreeTraverser here
            TreeTraverser treeTraverser = new TreeTraverser(this.Dest);

            foreach(TreeTraverser.FolderEntry folder in treeTraverser.ListFolders()) {
                yield return new EntityRecord(folder.RelPath, Entity.Folder);
                foreach (TreeTraverser.FileEntry file in folder.GetFiles()) {
                    yield return new EntityRecord(file.RelPath, Entity.File);
                }
            }
        }