lsst.base 22.0.1-3-gb9f71e8+f3d053c481
LSST Data Management Base Package
library.cc
Go to the documentation of this file.
1#include "lsst/base/library.h"
2
3namespace lsst {
4namespace base {
5
6namespace {
7
9bool endsWith(std::string const& str, std::string const& end)
10{
11 return str.size() >= end.size() && str.compare(str.size() - end.size(), end.size(), end) == 0;
12}
13
14} // anonymous namespace
15
16
18{
19#ifdef __APPLE__
20 return ".dylib";
21#else
22 return ".so";
23#endif
24}
25
26
28{
29 if (endsWith(name, ".so") || endsWith(name, ".dylib")) {
30 // User asked for a library with a certain extension, so give it to them
31 return name;
32 }
33 return name + libraryExtension();
34}
35
36
37bool canLoadLibrary(std::string const& libName)
38{
39 return dlopen(getLibraryFilename(libName).c_str(), RTLD_NOW | RTLD_GLOBAL);
40}
41
42
43}} // lsst::base
T compare(T... args)
T end(T... args)
bool canLoadLibrary(std::string const &libName)
Return whether we can load a library.
Definition: library.cc:37
std::string getLibraryFilename(std::string const &name)
Get filename for library.
Definition: library.cc:27
std::string libraryExtension()
Return filename extension for libraries.
Definition: library.cc:17
Definition: mainpage.dox:1
T size(T... args)