public static ManifestIndex FromFile(string manifestPath, string root) { ManifestIndex index = new ManifestIndex(); foreach (string line in File.ReadAllLines(manifestPath)) { index.IndexLine(line); } return(index); }
private static List <Descriptor> CollectForDeletion(string manifest, string root) { ManifestIndex index = ManifestIndex.FromFile(manifest, root); List <Descriptor> toDelete = new List <Descriptor> (); foreach (string topLevel in index.TopLevel) { toDelete.AddRange(CollectForDeletion(root + topLevel, index)); } return(toDelete); }
// Collects a list of files and directories that need to be deleted private static List <Descriptor> CollectForDeletion(string path, ManifestIndex index) { List <Descriptor> toDelete = new List <Descriptor> (); DirectoryInfo directory = new DirectoryInfo(path); foreach (FileInfo file in directory.GetFiles()) { HandleFile(file, index, ref toDelete); } foreach (string dir in Directory.GetDirectories(path)) { HandleDirectory(FileUtils.NormalizePathForPlatform(dir), index, ref toDelete); } return(toDelete); }
private static void HandleDirectory(string directory, ManifestIndex index, ref List <Descriptor> toDelete) { if (index.Ignored(directory)) { Utils.Log("Ignoring {0}", directory); return; } if (!index.Kept(directory)) { toDelete.Add(new Descriptor { Path = directory, Type = Descriptor.FileType.Directory }); } toDelete.AddRange(CollectForDeletion(directory, index)); }
private static void HandleFile(FileInfo file, ManifestIndex index, ref List <Descriptor> toDelete) { string absolute = FileUtils.NormalizePathForPlatform(file.FullName); if (index.Ignored(absolute)) { Utils.Log("Ignoring {0}", absolute); return; } if (IsHidden(file)) { return; } if (!index.Kept(absolute)) { toDelete.Add(new Descriptor { Path = absolute, Type = Descriptor.FileType.File }); } }
// Collects a list of files and directories that need to be deleted private static List<Descriptor> CollectForDeletion(string path, ManifestIndex index) { List<Descriptor> toDelete = new List<Descriptor> (); DirectoryInfo directory = new DirectoryInfo (path); foreach (FileInfo file in directory.GetFiles ()) { HandleFile (file, index, ref toDelete); } foreach (string dir in Directory.GetDirectories (path)) { HandleDirectory (FileUtils.NormalizePathForPlatform (dir), index, ref toDelete); } return toDelete; }
private static void HandleDirectory(string directory, ManifestIndex index, ref List<Descriptor> toDelete) { if (index.Ignored (directory)) { Utils.Log ("Ignoring {0}", directory); return; } if (!index.Kept (directory)) { toDelete.Add (new Descriptor { Path = directory, Type = Descriptor.FileType.Directory }); } toDelete.AddRange (CollectForDeletion (directory, index)); }
private static void HandleFile(FileInfo file, ManifestIndex index, ref List<Descriptor> toDelete) { string absolute = FileUtils.NormalizePathForPlatform (file.FullName); if (index.Ignored (absolute)) { Utils.Log ("Ignoring {0}", absolute); return; } if (IsHidden (file)) { return; } if (!index.Kept (absolute)) { toDelete.Add (new Descriptor { Path = absolute, Type = Descriptor.FileType.File }); } }
public static ManifestIndex FromFile(string manifestPath, string root) { ManifestIndex index = new ManifestIndex (); foreach (string line in File.ReadAllLines (manifestPath)) { index.IndexLine (line); } return index; }