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

Function getProjLibraryPath

src/proj_loader.cpp:105–130  ·  view source on GitHub ↗

Returns the path to the proj lib if lib exists, or optionally the path with the latest lib version in the directory

Source from the content-addressed store, hash-verified

103#if defined(__unix__) || defined(__APPLE__)
104/// Returns the path to the proj lib if lib exists, or optionally the path with the latest lib version in the directory
105std::string getProjLibraryPath(const std::string &dir, bool withLatestVersion = false) {
106 std::regex projRegex(R"(libproj\.so(\.\d+)+$)");
107 std::vector<std::string> candidates;
108
109 if (!std::filesystem::exists(dir)) return "";
110
111 for (const auto& entry : std::filesystem::directory_iterator(dir)) {
112 try {
113 std::string file = entry.path().filename().string();
114 if (std::regex_match(file, projRegex)) {
115 if (withLatestVersion == false) {
116 return dir;
117 }
118 candidates.push_back(entry.path().string());
119 }
120 } catch (const std::filesystem::filesystem_error&) {
121 continue;
122 }
123 }
124
125 if (candidates.empty()) return "";
126
127 // Sort by latest version (.so.22 / .so.25.2.1 etc.)
128 std::sort(candidates.begin(), candidates.end());
129 return candidates.back(); // latest version
130}
131#endif
132
133/// Compare lib version numbers. Return ture if v1 latest version

Calls 4

emptyMethod · 0.80
stringMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected