MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / SharedLib_Load

Function SharedLib_Load

src/vrcore/sharedlibtools_public.cpp:16–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#endif
15
16SharedLibHandle 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
44void *SharedLib_GetFunction( SharedLibHandle lib, const char *pchFunctionName)
45{

Callers 1

VR_LoadHmdSystemInternalFunction · 0.85

Calls 1

UTF8to16Function · 0.70

Tested by

no test coverage detected