Skip to content
Permalink
Browse files

QGIS_PROVIDER_FILE: provider regexp pattern environment variable

  • Loading branch information
blazek committed May 11, 2015
1 parent aaabad2 commit 3b00dc12583ebcd6148a22fa36c61c0e2a18f7bb
Showing with 22 additions and 0 deletions.
  1. +17 −0 src/core/qgsproviderregistry.cpp
  2. +5 −0 src/core/qgsproviderregistry.h
@@ -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() )
{
@@ -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
{

0 comments on commit 3b00dc1

Please sign in to comment.
You can’t perform that action at this time.