comparison Plugins/Engine/SharedLibrary.cpp @ 1630:ffd23c0104af

"/system" URI gives information about the plugins used for storage area and DB back-end
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Sep 2015 13:26:45 +0200
parents c17b1142caab
children 0d074f5f6069
comparison
equal deleted inserted replaced
1629:bad4772b605c 1630:ffd23c0104af
34 #include "SharedLibrary.h" 34 #include "SharedLibrary.h"
35 35
36 #include "../../Core/Logging.h" 36 #include "../../Core/Logging.h"
37 #include "../../Core/Toolbox.h" 37 #include "../../Core/Toolbox.h"
38 38
39 #include <boost/filesystem.hpp>
40
39 #if defined(_WIN32) 41 #if defined(_WIN32)
40 #include <windows.h> 42 #include <windows.h>
41 #elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 43 #elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
42 #include <dlfcn.h> 44 #include <dlfcn.h>
43 #else 45 #else
44 #error Support your platform here 46 #error Support your platform here
45 #endif 47 #endif
46 48
47 namespace Orthanc 49 namespace Orthanc
48 { 50 {
49 SharedLibrary::SharedLibrary(const std::string& path) : 51 SharedLibrary::SharedLibrary(const std::string& path) : handle_(NULL)
50 path_(path),
51 handle_(NULL)
52 { 52 {
53 path_ = boost::filesystem::canonical(path).string();
54
53 #if defined(_WIN32) 55 #if defined(_WIN32)
54 handle_ = ::LoadLibraryA(path.c_str()); 56 handle_ = ::LoadLibraryA(path_.c_str());
55 if (handle_ == NULL) 57 if (handle_ == NULL)
56 { 58 {
57 LOG(ERROR) << "LoadLibrary(" << path << ") failed: Error " << ::GetLastError(); 59 LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError();
58 throw OrthancException(ErrorCode_SharedLibrary); 60 throw OrthancException(ErrorCode_SharedLibrary);
59 } 61 }
60 62
61 #elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 63 #elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
62 handle_ = ::dlopen(path.c_str(), RTLD_NOW); 64 handle_ = ::dlopen(path_.c_str(), RTLD_NOW);
63 if (handle_ == NULL) 65 if (handle_ == NULL)
64 { 66 {
65 std::string explanation; 67 std::string explanation;
66 const char *tmp = ::dlerror(); 68 const char *tmp = ::dlerror();
67 if (tmp) 69 if (tmp)
68 { 70 {
69 explanation = ": Error " + std::string(tmp); 71 explanation = ": Error " + std::string(tmp);
70 } 72 }
71 73
72 LOG(ERROR) << "dlopen(" << path << ") failed" << explanation; 74 LOG(ERROR) << "dlopen(" << path_ << ") failed" << explanation;
73 throw OrthancException(ErrorCode_SharedLibrary); 75 throw OrthancException(ErrorCode_SharedLibrary);
74 } 76 }
75 77
76 #else 78 #else
77 #error Support your platform here 79 #error Support your platform here