Skip to content

Commit

Permalink
QGIS_PROVIDER_FILE: provider regexp pattern environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed May 16, 2015
1 parent aaabad2 commit 3b00dc1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/core/qgsproviderregistry.cpp
Expand Up @@ -94,11 +94,28 @@ QgsProviderRegistry::QgsProviderRegistry( QString pluginPath )
return;
}

// provider file regex pattern, only files matching the pattern are loaded if the variable is defined
QString filePattern = getenv( "QGIS_PROVIDER_FILE" );
QRegExp fileRegexp;
if ( !filePattern.isEmpty() )
{
fileRegexp.setPattern( filePattern );
}

QListIterator<QFileInfo> it( mLibraryDirectory.entryInfoList() );
while ( it.hasNext() )
{
QFileInfo fi( it.next() );

if ( !fileRegexp.isEmpty() )
{
if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
{
QgsDebugMsg( "provider " + fi.fileName() + " skipped because doesn't match pattern " + filePattern );
continue;
}
}

QLibrary myLib( fi.filePath() );
if ( !myLib.load() )
{
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsproviderregistry.h
Expand Up @@ -36,6 +36,11 @@ class QgsCoordinateReferenceSystem;
* A registry / canonical manager of data providers.
This is a Singleton class that manages data provider access.
Loaded providers may be restricted using QGIS_PROVIDER_FILE environment variable.
QGIS_PROVIDER_FILE is regexp pattern applied to provider file name (not provider key).
For example, if the variable is set to gdal|ogr|postgres it will load only providers gdal,
ogr and postgres.
*/
class CORE_EXPORT QgsProviderRegistry
{
Expand Down

0 comments on commit 3b00dc1

Please sign in to comment.