HardcodedGameLocationProvider.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.IO;
  3. namespace OpenVIII
  4. {
  5. public sealed class HardcodedGameLocationProvider
  6. {
  7. private readonly string[] _knownPaths;
  8. public HardcodedGameLocationProvider(string[] knownPaths)
  9. {
  10. _knownPaths = knownPaths ?? throw new ArgumentNullException(nameof(knownPaths));
  11. }
  12. public bool FindGameLocation(out GameLocation gameLocation)
  13. {
  14. //using (var errors = new ExceptionList())
  15. //{
  16. foreach (var path in _knownPaths)
  17. {
  18. try
  19. {
  20. if (!Directory.Exists(path))
  21. continue;
  22. gameLocation = new GameLocation(path);
  23. //errors.Clear();
  24. return true;
  25. }
  26. catch (Exception ex)
  27. {
  28. ex.Rethrow();
  29. //errors.Add(ex);
  30. }
  31. }
  32. //}
  33. gameLocation = null;
  34. return false;
  35. }
  36. }
  37. }