diff options
author | Roland Reichwein <mail@reichwein.it> | 2024-05-31 17:04:21 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2024-05-31 17:04:21 +0200 |
commit | 9b6c531505ff74f119bff6facae35c10801b2c6c (patch) | |
tree | e8efa038553588a7f4bde3f3ebe2cc3c996baf73 /file.cpp | |
parent | 92be2196d6515f854295b0b830ad7dd4b97bb956 (diff) |
Link dynamic lib, test
Diffstat (limited to 'file.cpp')
-rw-r--r-- | file.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -100,10 +100,15 @@ std::filesystem::path soname_short(const std::filesystem::path& p) // file1.so.1 -> file1 std::string dynamic_lib_name(const std::filesystem::path& p) { - std::string result {p.stem().string()}; + std::string result {p.filename().string()}; if (result.substr(0, 3) == "lib") { result = result.substr(3); } + size_t dotpos{result.find('.')}; + if (dotpos == std::string::npos) { + throw std::runtime_error("Unexpected path: Expected dot (.) in: "s + p.string()); + } + result = result.substr(0, dotpos); return result; } @@ -120,6 +125,15 @@ std::filesystem::path simplified_path(const std::filesystem::path& p) return p; } +std::filesystem::path lib_path(const std::filesystem::path& p) +{ + fs::path result{p.parent_path()}; + if (result.empty()) { + result = "."; + } + return result; +} + bool is_executable_command(const std::string& file) { std::vector<std::string> paths {Reichwein::Stringhelper::split(env_value("PATH"), ":")}; |