InstallLayout.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. * Where the installer puts things.
  20. *
  21. * The installation directory is also the working directory of the game, which reads its data from
  22. * "<dir>/data/..." and its intermediate world map files from "<dir>/temp/world_models".
  23. *
  24. * Every path is relative to the installation directory unless stated otherwise.
  25. */
  26. namespace InstallLayout{
  27. /**
  28. * Gets the directory with the game data.
  29. *
  30. * @param[in] root Installation directory, ending with '/'.
  31. */
  32. std::string DataDir(const std::string& root);
  33. /**
  34. * Gets the directory with the intermediate files.
  35. *
  36. * @param[in] root Installation directory, ending with '/'.
  37. */
  38. std::string TempDir(const std::string& root);
  39. /**
  40. * Directories created inside the data directory.
  41. */
  42. const std::vector<std::string>& DataSubdirs();
  43. /**
  44. * Directories created inside the temp directory.
  45. */
  46. const std::vector<std::string>& TempSubdirs();
  47. /**
  48. * Temp directories that the game itself needs, so they are not removed when cleaning up.
  49. */
  50. const std::vector<std::string>& KeptTempSubdirs();
  51. /**
  52. * Temp directories that are removed when cleaning up.
  53. */
  54. std::vector<std::string> RemovableTempSubdirs();
  55. /**
  56. * Directories the game registers as resource locations, relative to the installation directory.
  57. */
  58. const std::vector<std::string>& GameResourceDirs();
  59. /**
  60. * Calculates the installation directory from the settings of older versions, which stored the configuration
  61. * directory and the data directory (<installation directory>/data) separately.
  62. *
  63. * @param[in] legacy_data_dir Old data directory setting, can be empty.
  64. * @param[in] legacy_config_dir Old configuration directory setting, can be empty.
  65. * @param[in] default_dir Directory to use when there is nothing to migrate.
  66. */
  67. std::string MigrateInstallDir(
  68. std::string legacy_data_dir, const std::string& legacy_config_dir, const std::string& default_dir
  69. );
  70. }