| 102 | } |
| 103 | |
| 104 | void SharedLibrary::Load(int flags) |
| 105 | { |
| 106 | if (d->m_Handle) throw std::logic_error(std::string("Library already loaded: ") + GetFilePath()); |
| 107 | std::string libPath = GetFilePath(); |
| 108 | #ifdef US_PLATFORM_POSIX |
| 109 | d->m_Handle = dlopen(libPath.c_str(), flags); |
| 110 | if (!d->m_Handle) |
| 111 | { |
| 112 | const char* err = dlerror(); |
| 113 | throw std::runtime_error(err ? std::string(err) : (std::string("Error loading ") + libPath)); |
| 114 | } |
| 115 | #else |
| 116 | d->m_Handle = LoadLibrary(libPath.c_str()); |
| 117 | if (!d->m_Handle) |
| 118 | { |
| 119 | std::string errMsg = "Loading "; |
| 120 | errMsg.append(libPath).append("failed with error: ").append(GetLastErrorStr()); |
| 121 | |
| 122 | throw std::runtime_error(errMsg); |
| 123 | } |
| 124 | #endif |
| 125 | } |
| 126 | |
| 127 | void SharedLibrary::Load() |
| 128 | { |
no test coverage detected