MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / GetInstallPath

Function GetInstallPath

src/openrct2/platform/Platform.Linux.cpp:140–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 }
139
140 std::string GetInstallPath()
141 {
142 // 1. Try command line argument
143 if (!gCustomOpenRCT2DataPath.empty())
144 {
145 return Path::GetAbsolute(gCustomOpenRCT2DataPath);
146 }
147 // 2. Try {${exeDir},${cwd},/}/{data,standard system app directories}
148 // exeDir should come first to allow installing into build dir
149 // clang-format off
150 const std::string prefixes[]{
151 Path::GetDirectory(Platform::GetCurrentExecutablePath()),
152 GetCurrentWorkingDirectory(),
153 "/"
154 };
155 static constexpr u8string_view SearchLocations[] = {
156 "/data",
157 "../share/openrct2",
158 "/usr/local/share/openrct2",
159 "/var/lib/openrct2",
160 "/usr/share/openrct2",
161 #ifdef __HAIKU__
162 "/boot/system/data/openrct2",
163 "/boot/home/config/data/openrct2",
164 "/boot/system/non-packaged/data/openrct2",
165 "/boot/home/config/non-packaged/data/openrct2",
166 #endif
167 };
168 // clang-format on
169 for (const auto& prefix : prefixes)
170 {
171 for (const auto searchLocation : SearchLocations)
172 {
173 auto prefixedPath = Path::Combine(prefix, searchLocation);
174 LOG_VERBOSE("Looking for OpenRCT2 data in %s", prefixedPath.c_str());
175 if (Path::DirectoryExists(prefixedPath))
176 {
177 return prefixedPath;
178 }
179 }
180 }
181 return "/";
182 }
183
184 std::string GetCurrentExecutablePath()
185 {

Callers 1

Calls 7

GetAbsoluteFunction · 0.85
GetDirectoryFunction · 0.85
DirectoryExistsFunction · 0.85
GetCurrentExecutablePathFunction · 0.70
CombineFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected