MCPcopy Create free account
hub / github.com/LAStools/LAStools / findProjLibInStandartPathsRecursive

Function findProjLibInStandartPathsRecursive

src/proj_loader.cpp:195–234  ·  view source on GitHub ↗

Search for the PROJ library within the standard installation directories by recursively traversing them.

Source from the content-addressed store, hash-verified

193
194/// Search for the PROJ library within the standard installation directories by recursively traversing them.
195static std::string findProjLibInStandartPathsRecursive(std::set<std::filesystem::path>& searchedPaths) {
196 const char* homeDir = nullptr;
197 std::vector<std::filesystem::path> pathsToCheck;
198
199#ifdef _WIN32
200 // Windows-Standardpfade
201 pathsToCheck.push_back("C:\\Program Files\\");
202 pathsToCheck.push_back("C:\\Program Files (x86)\\");
203
204 const char* userProfile = getenv("USERPROFILE");
205 if (userProfile) {
206 pathsToCheck.push_back(std::filesystem::path(userProfile) / "AppData/Local/Programs");
207 }
208#else
209 // Linux/macOS-Standardpfade
210 const std::string systemLibPaths[] = {
211 "/usr/lib/x86_64-linux-gnu/", "/usr/lib/", "/usr/bin/", "/usr/local/lib/", "/usr/local/bin/", "/opt/", "/usr/share/", "/lib/x86_64-linux-gnu/"};
212 homeDir = getHomeDirectory();
213
214 for (const auto& p : systemLibPaths) pathsToCheck.push_back(p);
215 if (homeDir) pathsToCheck.push_back(std::filesystem::path(homeDir) / ".local/lib");
216#endif
217 // 1. Recursive fallback
218 for (const auto& basePath : pathsToCheck) {
219 std::string logEntry = basePath.string() + " (searching this path recursively)";
220 searchedPaths.insert(logEntry);
221 try {
222 for (const auto& entry : std::filesystem::recursive_directory_iterator(basePath)) {
223 if (std::filesystem::exists(entry) && entry.is_directory()) {
224 // searchedPaths.insert(entry.path());
225 const std::string resultPath = findLatestProjLibraryPath(entry.path().string());
226 if (!resultPath.empty()) return resultPath;
227 }
228 }
229 } catch (const std::filesystem::filesystem_error&) {
230 continue;
231 }
232 }
233 return "";
234}
235
236/// Search for the PROJ library within the standard installation directories.
237static std::string findProjLibInStandartPaths(std::set<std::filesystem::path>& searchedPaths) {

Callers 1

load_proj_libraryFunction · 0.85

Calls 5

getHomeDirectoryFunction · 0.85
emptyMethod · 0.80
stringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected