std::string ComponentPluginManager::GetSharedLibNameFromPluginName(const std::string& pluginName) { std::ostringstream os; #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) os << pluginName << GetLibExtension(); #else os << "lib" << pluginName << GetLibExtension(); #endif return os.str(); }
void SpringOptionsTab::OnBrowseSync( wxCommandEvent& /*unused*/ ) { wxString filefilter = wxString( _( "Library" ) ) << _T( "(*" ) << GetLibExtension() << _T( ")|*" ) + GetLibExtension(); #ifdef __WXMAC__ filefilter << _T( "|" ) << _( "Library" ) << _T( "(*.dylib)|*.dylib" ); #endif filefilter << _T( "|" ) << wxString( _( "Any File" ) ) << _T( " (*.*)|*.*" ); wxFileDialog pick( this, _( "Choose UnitSync library" ), wxPathOnly( sett().GetCurrentUsedSpringBinary() ), _T( "unitsync" ) + GetLibExtension(), wxString( _( "Library" ) ) + _T( "(*" ) + GetLibExtension() + _T( ")|*" ) + GetLibExtension() + _T( "|" ) + wxString( _( "Any File" ) ) + _T( " (*.*)|*.*" ) ); if ( pick.ShowModal() == wxID_OK ) m_sync_edit->SetValue( pick.GetPath() ); }
/** load all dlls in dir and check for plugin factories */ void ComponentPluginManager::LoadPluginsInDir(const std::string& path) { std::string cleanedPath(path); if (path[path.size() - 1] == GetNativePathSeparator()) { // remove the trailing path separator as this causes issues... cleanedPath = path.substr(0, path.size() - 1); } if(!GetSystemInterface()->FileExists(cleanedPath)) { LOG_ALWAYS("Plugin folder not found! Path: " + cleanedPath); return; } std::string libExtension = GetLibExtension(); LOG_DEBUG("Looking for plugins with extension: " + libExtension); // get libs from directory SystemInterface::DirectoryContents files = GetSystemInterface()->GetDirectoryContents(cleanedPath); // for each library in dir SystemInterface::DirectoryContents::const_iterator i; for(i = files.begin(); i != files.end(); ++i) { std::string fileName = *i; if(fileName.size() <= libExtension.size()) continue; std::string ending = fileName.substr(fileName.size() - libExtension.size(), fileName.size()); if(ending.compare(libExtension) != 0) { continue; } std::ostringstream libpath; libpath << cleanedPath << GetNativePathSeparator() << fileName; AddPlugin(libpath.str()); LOG_DEBUG("Loaded plugin: " + libpath.str()); } }