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.

27 lines
692 B

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