示例#1
0
 public abstract void PurgeFiles(IEnumerable<string> files, IEnumerable<string> folders, PurgeProgressHandler handler=null);
示例#2
0
        public override void PurgeFiles(IEnumerable <string> filesIn, IEnumerable <string> foldersIn, PurgeProgressHandler handler = null)
        {
            HashSet <string> limitFiles   = new HashSet <string>(filesIn.Select(x => x.Replace('\\', '/')));
            HashSet <string> limitFolders = new HashSet <string>(foldersIn.Select(x => x.Replace('\\', '/')));

            // We can't modify the list we're iterating over, and DeleteFile does modify it
            string[] iterateFiles = this.files.ToArray();
            foreach (string file in iterateFiles)
            {
                if (!limitFiles.Contains(file))
                {
                    this.DeleteFile(file);
                    if (handler != null && !handler(Entity.File, file, true))
                    {
                        return;
                    }
                }
                else
                {
                    if (handler != null && !handler(Entity.File, file, false))
                    {
                        return;
                    }
                }
            }

            string[] iterateFolders = this.folders.ToArray();
            foreach (string folder in iterateFolders)
            {
                if (!limitFolders.Contains(folder))
                {
                    this.DeleteFolder(folder);
                    if (handler != null && !handler(Entity.Folder, folder, true))
                    {
                        return;
                    }
                }
                else
                {
                    if (handler != null && !handler(Entity.Folder, folder, false))
                    {
                        return;
                    }
                }
            }
        }
示例#3
0
        public override void PurgeFiles(IEnumerable<string> filesIn, IEnumerable<string> foldersIn, PurgeProgressHandler handler=null) {
            HashSet<string> limitFiles = new HashSet<string>(filesIn.Select(x => x.Replace('\\', '/')));
            HashSet<string> limitFolders = new HashSet<string>(foldersIn.Select(x => x.Replace('\\', '/')));

            // We can't modify the list we're iterating over, and DeleteFile does modify it
            string[] iterateFiles = this.files.ToArray();
            foreach (string file in iterateFiles) {
                if (!limitFiles.Contains(file)) {
                    this.DeleteFile(file);
                    if (handler != null && !handler(Entity.File, file, true))
                        return;
                }
                else {
                    if (handler != null && !handler(Entity.File, file, false))
                        return;
                }
            }

            string[] iterateFolders = this.folders.ToArray();
            foreach (string folder in iterateFolders) {
                if (!limitFolders.Contains(folder)) {
                    this.DeleteFolder(folder);
                    if (handler != null && !handler(Entity.Folder, folder, true))
                        return;
                }
                else {
                    if (handler != null && !handler(Entity.Folder, folder, false))
                        return;
                }
            }
        }
示例#4
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) { }
            }
        }
示例#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) { }
            }
        }
示例#6
0
 public abstract void PurgeFiles(IEnumerable <string> files, IEnumerable <string> folders, PurgeProgressHandler handler = null);