| 14 | #endif |
| 15 | |
| 16 | SharedLibHandle SharedLib_Load( const char *pchPath, std::string *pErrStr ) |
| 17 | { |
| 18 | SharedLibHandle pHandle = nullptr; |
| 19 | #if defined( _WIN32) |
| 20 | std::wstring wsFixedPath = UTF8to16( pchPath ); |
| 21 | |
| 22 | pHandle = ( SharedLibHandle )LoadLibraryExW( wsFixedPath.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); |
| 23 | #elif defined(POSIX) |
| 24 | pHandle = (SharedLibHandle) dlopen( pchPath, RTLD_LOCAL|RTLD_NOW ); |
| 25 | #endif |
| 26 | |
| 27 | if ( pHandle == nullptr && pErrStr ) |
| 28 | { |
| 29 | #if defined( _WIN32) |
| 30 | // TODO: Consider using FormatMessage to get an error string for this error code |
| 31 | *pErrStr = std::to_string( GetLastError() ); |
| 32 | #elif defined(POSIX) |
| 33 | char * pErr = dlerror(); |
| 34 | if ( pErr ) |
| 35 | { |
| 36 | *pErrStr = std::string ( pErr ); |
| 37 | } |
| 38 | #endif |
| 39 | } |
| 40 | |
| 41 | return pHandle; |
| 42 | } |
| 43 | |
| 44 | void *SharedLib_GetFunction( SharedLibHandle lib, const char *pchFunctionName) |
| 45 | { |
no test coverage detected