You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
596 B

  1. using System.IO;
  2. using System.Linq;
  3. namespace IPA.Injector.Backups
  4. {
  5. internal static class BackupManager
  6. {
  7. public static BackupUnit FindLatestBackup(string dir)
  8. {
  9. new DirectoryInfo(dir).Create();
  10. return new DirectoryInfo(dir)
  11. .GetDirectories()
  12. .OrderByDescending(p => p.Name)
  13. .Select(p => BackupUnit.FromDirectory(p, dir))
  14. .FirstOrDefault();
  15. }
  16. public static bool HasBackup(string dir)
  17. {
  18. return FindLatestBackup(dir) != null;
  19. }
  20. }
  21. }