LSSTApplications  18.1.0
LSSTDataManagementBasePackage
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 
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 
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 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
STL class.
A base class for image defects.
T size(T... args)
bool canLoadLibrary(std::string const &libName)
Return whether we can load a library.
Definition: library.cc:37
int end
T compare(T... args)