InstallVerifier.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <string>
  17. #include <vector>
  18. /**
  19. * A thing that is missing in an installation.
  20. */
  21. struct VerifyProblem{
  22. /**
  23. * Part of the installation it belongs to ("Field maps", "World map"...).
  24. */
  25. std::string group;
  26. /**
  27. * What is missing.
  28. */
  29. std::string message;
  30. };
  31. /**
  32. * Result of verifying an installation.
  33. */
  34. struct VerifyResult{
  35. /**
  36. * What is missing.
  37. */
  38. std::vector<VerifyProblem> problems;
  39. /**
  40. * Number of checks done.
  41. */
  42. int checked = 0;
  43. /**
  44. * True if nothing is missing.
  45. */
  46. bool Ok() const{return problems.empty();}
  47. };
  48. /**
  49. * Checks that an installation has everything the game needs.
  50. *
  51. * It only looks at the existence of files, it doesn't open them. Parts of the installation can be skipped on purpose
  52. * (for example the music), so a missing item is reported under the part it belongs to.
  53. *
  54. * @param[in] root Installation directory.
  55. * @param[in] reference_dir V-Gears "data" folder of the game (the one copied to the installation). If not empty,
  56. * every file in it must exist in the installation too. It can be empty.
  57. */
  58. VerifyResult VerifyInstallation(const std::string& root, const std::string& reference_dir = "");