Esempio n. 1
0
        public static BackupUnit FromDirectory(DirectoryInfo directory, PatchContext context)
        {
            var unit = new BackupUnit(context, directory.Name);

            // Read Manifest
            if (unit._manifestFile.Exists)
            {
                var manifest = File.ReadAllText(unit._manifestFile.FullName);
                foreach (var line in manifest.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                {
                    unit._files.Add(line);
                }
            }
            else
            {
                foreach (var file in directory.GetFiles("*", SearchOption.AllDirectories))
                {
                    if (file.Name == _ManifestFileName)
                    {
                        continue;
                    }
                    var relativePath = file.FullName.Substring(directory.FullName.Length + 1);
                    unit._files.Add(relativePath);
                }
            }

            return(unit);
        }
Esempio n. 2
0
 public static BackupUnit FindLatestBackup(PatchContext context)
 {
     return(new DirectoryInfo(context.BackupPath)
            .GetDirectories()
            .OrderByDescending(p => p.Name)
            .Select(p => BackupUnit.FromDirectory(p, context))
            .FirstOrDefault());
 }
Esempio n. 3
0
        public static BackupUnit FromDirectory(DirectoryInfo directory, PatchContext context)
        {
            var unit = new BackupUnit(context, directory.Name);

            // Parse directory
            foreach (var file in directory.GetFiles("*", SearchOption.AllDirectories))
            {
                var relativePath = file.FullName.Substring(directory.FullName.Length + 1);
                unit._Files.Add(relativePath);
            }

            return(unit);
        }