public Entry(Area area, Entry parent, DirectoryInfo info, string canonicalName, bool ignored) { Parent = parent; Area = area; CanonicalName = canonicalName; DirectoryInfo = info; ModificationTime = DirectoryInfo.LastWriteTimeUtc; Ignored = ignored; m_Hash = string.Empty; if (info.Attributes.HasFlag(FileAttributes.Hidden)) Attributes = Attributes | Objects.Attributes.Hidden; if (info.Attributes.HasFlag(FileAttributes.ReadOnly)) Attributes = Attributes | Objects.Attributes.ReadOnly; if (Utilities.Symlink.Exists(info)) { Attributes = Attributes | Objects.Attributes.Symlink; if (CanonicalName.EndsWith("/")) CanonicalName = canonicalName.Substring(0, canonicalName.Length - 1); } }
public Entry(Area area, Entry parent, FileInfo info, string canonicalName, bool ignored) { Parent = parent; Area = area; CanonicalName = info.Name == ".vrmeta" ? info.Name : canonicalName; Info = info; Ignored = ignored; GetInfo(); }
private static List<Entry> PopulateList(Area area, Entry parentEntry, DirectoryInfo info, string subdirectory, DirectoryInfo adminFolder, bool ignoreDirectory) { List<Entry> result = new List<Entry>(); if (area.InExtern(info)) return result; bool ignoreContents = false; string slashedSubdirectory = subdirectory; if (subdirectory != string.Empty) { if (slashedSubdirectory[slashedSubdirectory.Length - 1] != '/') slashedSubdirectory += '/'; if (area != null && area.Directives != null && area.Directives.Include != null) { ignoreDirectory = true; foreach (var y in area.Directives.Include.Directories) { if (y.StartsWith(slashedSubdirectory, StringComparison.OrdinalIgnoreCase)) { if (slashedSubdirectory.Length <= y.Length - 1) ignoreContents = true; ignoreDirectory = false; break; } else if (slashedSubdirectory.StartsWith(y)) { ignoreDirectory = false; break; } } if (area.Directives.Include.RegexDirectoryPatterns != null) { foreach (var y in area.Directives.Include.RegexDirectoryPatterns) { if (y.IsMatch(slashedSubdirectory)) { ignoreDirectory = false; break; } } } } if (area != null && area.Directives != null && area.Directives.Ignore != null && area.Directives.Ignore.RegexDirectoryPatterns != null) { foreach (var y in area.Directives.Ignore.Directories) { if (slashedSubdirectory.StartsWith(y, StringComparison.OrdinalIgnoreCase)) { ignoreDirectory = true; break; } } foreach (var y in area.Directives.Ignore.RegexDirectoryPatterns) { if (y.IsMatch(slashedSubdirectory)) { ignoreDirectory = true; break; } } } if (area != null && area.Directives != null && area.Directives.Externals != null) { foreach (var x in area.Directives.Externals) { string extdir = x.Value.Location.Replace('\\', '/'); if (!extdir.EndsWith("/")) extdir += "/"; if (string.Equals(slashedSubdirectory, extdir, StringComparison.OrdinalIgnoreCase)) { return result; } } } parentEntry = new Entry(area, parentEntry, info, slashedSubdirectory, ignoreDirectory); result.Add(parentEntry); if (ignoreDirectory) return result; } // Don't add children for symlinks. if (Utilities.Symlink.Exists(info)) return result; List<Task<List<Entry>>> tasks = new List<Task<List<Entry>>>(); string prefix = string.IsNullOrEmpty(subdirectory) ? string.Empty : slashedSubdirectory; foreach (var x in info.GetFileSystemInfos()) { string fn = x.Name; string name = prefix + fn; if (x.Attributes.HasFlag(FileAttributes.Directory)) { if (fn == "." || fn == "..") continue; if (x.Name == ".versionr") continue; #if DEBUG if (true) #else if (Utilities.MultiArchPInvoke.IsRunningOnMono) #endif { result.AddRange(PopulateList(area, parentEntry, x as DirectoryInfo, name, adminFolder, ignoreDirectory)); } else { tasks.Add(Utilities.LimitedTaskDispatcher.Factory.StartNew(() => { return PopulateList(area, parentEntry, x as DirectoryInfo, name, adminFolder, ignoreDirectory); })); } } else if (!ignoreContents) { bool ignored = ignoreDirectory; if (!ignored && area != null && area.Directives != null && area.Directives.Include != null && area.Directives.Include.RegexFilePatterns != null) { ignored = true; foreach (var y in area.Directives.Include.RegexFilePatterns) { if (y.IsMatch(name)) { ignored = false; break; } } } int lastIndex = fn.LastIndexOf('.'); if (lastIndex > 0) { string ext = fn.Substring(lastIndex); if (!ignored && area != null && area.Directives != null && area.Directives.Include != null && area.Directives.Include.Extensions != null) { ignored = true; foreach (var y in area.Directives.Include.Extensions) { if (ext.Equals(y, StringComparison.OrdinalIgnoreCase)) { ignored = false; break; } } } if (!ignored && area != null && area.Directives != null && area.Directives.Ignore != null && area.Directives.Ignore.Extensions != null) { foreach (var y in area.Directives.Ignore.Extensions) { if (ext.Equals(y, StringComparison.OrdinalIgnoreCase)) { ignored = true; break; } } } } if (!ignored && area != null && area.Directives != null && area.Directives.Ignore != null && area.Directives.Ignore.RegexFilePatterns != null) { foreach (var y in area.Directives.Ignore.RegexFilePatterns) { if (y.IsMatch(name)) { ignored = true; break; } } } result.Add(new Entry(area, parentEntry, x as FileInfo, name, ignored)); } } if (tasks.Count > 0) { Task.WaitAll(tasks.ToArray()); foreach (var x in tasks) result.AddRange(x.Result); } return result; }