X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface.cxx;h=53b7b118174179807139737986a54f5e9a1ed93b;hb=e6bef8234ffd9030c68a6786466a08cf144b7871;hp=58e468d29e114cc2b802a22fab6cb1b8f90d07f2;hpb=10f490b762198b1e0fe5d4473874643243880883;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface.cxx b/lib/cpPlugins/Interface.cxx index 58e468d..53b7b11 100644 --- a/lib/cpPlugins/Interface.cxx +++ b/lib/cpPlugins/Interface.cxx @@ -6,6 +6,7 @@ # include #endif // cpPlugins_SYS_WINDOWS #include +#include // ------------------------------------------------------------------------- cpPlugins::Interface:: @@ -28,6 +29,26 @@ GetFilters( ) return( this->m_Filters ); } +// ------------------------------------------------------------------------- +void cpPlugins::Interface:: +GuessAccesiblePlugins( ) +{ + // Load environment configuration + char* path = std::getenv( "cpPlugins_PATHS" ); + if( path != NULL ) + { + std::vector< std::string > tokens; + cpPlugins::TokenizeString( tokens, path, "#" ); + for( auto tIt = tokens.begin( ); tIt != tokens.end( ); ++tIt ) + try { this->LoadPluginDir( *tIt ); } catch( ... ) { } + + } // fi + + // Load local path + auto lpath = cpPlugins::CanonicalPath( "." ); + try { this->LoadPluginDir( lpath ); } catch( ... ) { } +} + // ------------------------------------------------------------------------- bool cpPlugins::Interface:: LoadConfiguration( const std::string& filename ) @@ -39,18 +60,7 @@ LoadConfiguration( const std::string& filename ) this->UnloadAll( ); std::string line; while( std::getline( in, line ) ) - { - try - { - this->LoadPluginFile( line ); - } - catch( ... ) - { - // Do nothing - - } // yrt - - } // elihw + try { this->LoadPluginFile( line ); } catch( ... ) { } return( true ); } @@ -82,7 +92,9 @@ LoadPluginFile( const std::string& filename ) ); // Check if it was already loaded - if( this->m_DynLibraries.find( canonical_fn ) != this->m_DynLibraries.end( ) ) + if( + this->m_DynLibraries.find( canonical_fn ) != this->m_DynLibraries.end( ) + ) return; // Ok, try to load the library @@ -154,13 +166,15 @@ LoadPluginDir( const std::string& dirname ) { try { - this->LoadPluginFile( ent->d_name ); + this->LoadPluginFile( + dirname + + std::string( "/" ) + + ent->d_name + ); count++; } - catch( ... ) - { - // Ignore errors - } // yrt + catch( ... ) { } + } // elihw closedir( dir ); }