コード例 #1
0
        /// <summary>
        /// Helper function to support the Duplicati enumeration callback system
        /// </summary>
        /// <param name="rootpath">The root path to look in and use as filter base</param>
        /// <param name="callback">The callback function that collects the output</param>
        public void EnumerateFilesAndFolders(string rootpath, Duplicati.Library.Utility.Utility.EnumerationFilterDelegate callback)
        {
            //Under normal enumeration, the filter will prevent visiting subfolders for excluded folders
            //But when using USN all files/folders are present in the list, so we have to maintain
            // a list of subfolders that are excluded from the set
            System.Text.StringBuilder            local_filter    = new StringBuilder();
            System.Text.RegularExpressions.Regex excludedFolders = null;

            foreach (KeyValuePair <string, Win32USN.USN_RECORD> r in this.Records)
            {
                if (r.Key.StartsWith(rootpath, Utility.Utility.ClientFilenameStringComparision))
                {
                    bool isFolder = (r.Value.FileAttributes & Win32USN.EFileAttributes.Directory) != 0;

                    if (excludedFolders != null && excludedFolders.Match(r.Key).Success)
                    {
                        continue;
                    }

                    if (isFolder)
                    {
                        if (!callback(rootpath, r.Key, (System.IO.FileAttributes)((int)r.Value.FileAttributes & 0xff)))
                        {
                            if (local_filter.Length != 0)
                            {
                                local_filter.Append("|");
                            }
                            local_filter.Append("(");
                            local_filter.Append(Utility.Utility.ConvertGlobbingToRegExp(r.Key + "*"));
                            local_filter.Append(")");

                            if (Utility.Utility.IsFSCaseSensitive)
                            {
                                excludedFolders = new System.Text.RegularExpressions.Regex(local_filter.ToString());
                            }
                            else
                            {
                                excludedFolders = new System.Text.RegularExpressions.Regex(local_filter.ToString(), System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            }
                        }
                    }
                    else
                    {
                        if (local_filter.Length == 0 || !excludedFolders.IsMatch(r.Key))
                        {
                            callback(rootpath, r.Key, (System.IO.FileAttributes)((int)r.Value.FileAttributes & 0xff));
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: LinuxSnapshot.cs プロジェクト: vizapata/duplicati
 /// <summary>
 /// Enumerates all files and folders in the snapshot
 /// </summary>
 /// <param name="callback">The callback to invoke with each found path</param>
 /// <param name="errorCallback">The callback used to report errors</param>
 public IEnumerable <string> EnumerateFilesAndFolders(Duplicati.Library.Utility.Utility.EnumerationFilterDelegate callback, Duplicati.Library.Utility.Utility.ReportAccessError errorCallback)
 {
     return(m_entries.SelectMany(
                s => Utility.Utility.EnumerateFileSystemEntries(s.Key, callback, this.ListFolders, this.ListFiles, this.GetAttributes, errorCallback)
                ));
 }
コード例 #3
0
ファイル: NoSnapshot.cs プロジェクト: thotchkiss/duplicati
 /// <summary>
 /// Enumerates all files and folders in the snapshot
 /// </summary>
 /// <param name="callback">The callback to invoke with each found path</param>
 public IEnumerable <string> EnumerateFilesAndFolders(Duplicati.Library.Utility.Utility.EnumerationFilterDelegate callback)
 {
     return(m_sources.SelectMany(
                s => Utility.Utility.EnumerateFileSystemEntries(s, callback, this.ListFolders, this.ListFiles, this.GetAttributes)
                ));
 }