Exemple #1
0
        /// <summary>
        /// Filter supplied <c>files</c>, removing any files which itself, or one
        /// of its parent folders, is excluded by the <c>filter</c>.
        /// </summary>
        /// <param name="files">Files to filter</param>
        /// <param name="filter">Exclusion filter</param>
        /// <param name="cache">Cache of included and exculded files / folders</param>
        /// <param name="errorCallback"></param>
        /// <returns>Filtered files</returns>
        private IEnumerable <string> FilterExcludedFiles(IEnumerable <string> files,
                                                         Utility.Utility.EnumerationFilterDelegate filter, IDictionary <string, bool> cache, Utility.Utility.ReportAccessError errorCallback = null)
        {
            var result = new List <string>();

            foreach (var file in files)
            {
                var attr = m_snapshot.FileExists(file) ? m_snapshot.GetAttributes(file) : FileAttributes.Normal;
                try
                {
                    if (!filter(file, file, attr))
                    {
                        continue;
                    }

                    if (!IsFolderOrAncestorsExcluded(Utility.Utility.GetParent(file, true), filter, cache))
                    {
                        result.Add(file);
                    }
                }
                catch (System.Threading.ThreadAbortException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    errorCallback?.Invoke(file, file, ex);
                    filter(file, file, attr | Utility.Utility.ATTRIBUTE_ERROR);
                }
            }

            return(result);
        }
Exemple #2
0
 /// <summary>
 /// Extension method for ISnapshotService which determines whether the given path is a symlink.
 /// </summary>
 /// <param name="snapshot">ISnapshotService implementation</param>
 /// <param name="path">File or folder path</param>
 /// <returns>Whether the path is a symlink</returns>
 public static bool IsSymlink(this ISnapshotService snapshot, string path)
 {
     return(snapshot.IsSymlink(path, snapshot.GetAttributes(path)));
 }