* Determine the base (personal dir and game data dir) paths * @param exe the path to the executable */
| 751 | * @param exe the path to the executable |
| 752 | */ |
| 753 | void DetermineBasePaths(std::string_view exe) |
| 754 | { |
| 755 | std::string tmp; |
| 756 | const std::string homedir = GetHomeDir(); |
| 757 | #ifdef USE_XDG |
| 758 | if (auto xdg_data_home = GetEnv("XDG_DATA_HOME"); xdg_data_home.has_value()) { |
| 759 | tmp = *xdg_data_home; |
| 760 | tmp += PATHSEP; |
| 761 | tmp += PERSONAL_DIR[0] == '.' ? &PERSONAL_DIR[1] : PERSONAL_DIR; |
| 762 | AppendPathSeparator(tmp); |
| 763 | _searchpaths[SP_PERSONAL_DIR_XDG] = tmp; |
| 764 | |
| 765 | tmp += "content_download"; |
| 766 | AppendPathSeparator(tmp); |
| 767 | _searchpaths[SP_AUTODOWNLOAD_PERSONAL_DIR_XDG] = tmp; |
| 768 | } else if (!homedir.empty()) { |
| 769 | tmp = homedir; |
| 770 | tmp += PATHSEP ".local" PATHSEP "share" PATHSEP; |
| 771 | tmp += PERSONAL_DIR[0] == '.' ? &PERSONAL_DIR[1] : PERSONAL_DIR; |
| 772 | AppendPathSeparator(tmp); |
| 773 | _searchpaths[SP_PERSONAL_DIR_XDG] = tmp; |
| 774 | |
| 775 | tmp += "content_download"; |
| 776 | AppendPathSeparator(tmp); |
| 777 | _searchpaths[SP_AUTODOWNLOAD_PERSONAL_DIR_XDG] = tmp; |
| 778 | } else { |
| 779 | _searchpaths[SP_PERSONAL_DIR_XDG].clear(); |
| 780 | _searchpaths[SP_AUTODOWNLOAD_PERSONAL_DIR_XDG].clear(); |
| 781 | } |
| 782 | #endif |
| 783 | |
| 784 | #if !defined(WITH_PERSONAL_DIR) |
| 785 | _searchpaths[SP_PERSONAL_DIR].clear(); |
| 786 | #else |
| 787 | if (!homedir.empty()) { |
| 788 | tmp = std::move(homedir); |
| 789 | tmp += PATHSEP; |
| 790 | tmp += PERSONAL_DIR; |
| 791 | AppendPathSeparator(tmp); |
| 792 | _searchpaths[SP_PERSONAL_DIR] = tmp; |
| 793 | |
| 794 | tmp += "content_download"; |
| 795 | AppendPathSeparator(tmp); |
| 796 | _searchpaths[SP_AUTODOWNLOAD_PERSONAL_DIR] = tmp; |
| 797 | } else { |
| 798 | _searchpaths[SP_PERSONAL_DIR].clear(); |
| 799 | _searchpaths[SP_AUTODOWNLOAD_PERSONAL_DIR].clear(); |
| 800 | } |
| 801 | #endif |
| 802 | |
| 803 | #if defined(WITH_SHARED_DIR) |
| 804 | tmp = SHARED_DIR; |
| 805 | AppendPathSeparator(tmp); |
| 806 | _searchpaths[SP_SHARED_DIR] = tmp; |
| 807 | #else |
| 808 | _searchpaths[SP_SHARED_DIR].clear(); |
| 809 | #endif |
| 810 |
no test coverage detected