lsst.base
20.0.0-4-g4a2362f
LSST Data Management Base Package
src
library.cc
Go to the documentation of this file.
1
#include "
lsst/base/library.h
"
2
3
namespace
lsst
{
4
namespace
base {
5
6
namespace
{
7
9
bool
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
17
std::string
libraryExtension
()
18
{
19
#ifdef __APPLE__
20
return
".dylib"
;
21
#else
22
return
".so"
;
23
#endif
24
}
25
26
27
std::string
getLibraryFilename
(
std::string
const
& name)
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
37
bool
canLoadLibrary
(
std::string
const
& libName)
38
{
39
return
dlopen(
getLibraryFilename
(libName).c_str(), RTLD_LAZY | RTLD_GLOBAL);
40
}
41
42
43
}}
// lsst::base
std::string
STL class.
lsst::base::getLibraryFilename
std::string getLibraryFilename(std::string const &name)
Get filename for library.
Definition:
library.cc:27
std::string::size
T size(T... args)
lsst::base::libraryExtension
std::string libraryExtension()
Return filename extension for libraries.
Definition:
library.cc:17
std::string::compare
T compare(T... args)
library.h
lsst
Definition:
mainpage.dox:1
lsst::base::canLoadLibrary
bool canLoadLibrary(std::string const &libName)
Return whether we can load a library.
Definition:
library.cc:37
std::end
T end(T... args)
Generated on Tue Jul 14 2020 08:49:13 for lsst.base by
1.8.18