35 #ifndef BOOST_FILESYSTEM_VERSION
36 #define BOOST_FILESYSTEM_VERSION 2
38 #include <boost/filesystem.hpp>
40 #include "exceptions/WLibraryFetchFailed.h"
41 #include "exceptions/WLibraryLoadFailed.h"
42 #include "WSharedLib.h"
68 explicit data(
const std::string& path ):
70 m_hDLL( LoadLibrary( path.c_str() ) )
74 throw WLibraryLoadFailed( std::string(
"Could not load library \"" +
m_path +
"\" due to the error: " + errmsg() ) );
83 FreeLibrary( m_hDLL );
100 throw WLibraryFetchFailed( std::string(
"Could not fetch symbol \"" + name +
"\"" +
" due to the error: " + errmsg() ) );
116 return reinterpret_cast< void*
>(
findFunction( name ) );
124 static std::string errmsg()
128 FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, GetLastError(), 0,
129 reinterpret_cast< LPTSTR >( &lpMsgBuf ), 0, 0 );
133 msg.push_back( *p++ );
135 LocalFree( lpMsgBuf );
145 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
150 pthread_mutex_lock( &mutex );
154 pthread_mutex_unlock( &mutex );
179 assert( dlclose(
m_dl ) == 0 );
189 explicit data(
const std::string& path )
196 throw WLibraryLoadFailed( std::string(
"Could not load library \"" +
m_path +
"\" due to the error: " + dlerror() ) );
228 void* variable_ptr = dlsym(
m_dl, name.c_str() );
229 const char *err = dlerror();
232 throw WLibraryFetchFailed( std::string(
"Could not fetch symbol \"" + name +
"\"" +
" due to the error: " + err ) );
240 m_data( new
data( lib.native_file_string() ) )
245 m_data( new
data( rhs.m_data->m_path ) )