OGRDataSource *OGRWalkDriver::Open( const char * pszFilename, int bUpdate ) { if( EQUALN(pszFilename, "PGEO:", strlen("PGEO:")) ) return NULL; if( EQUALN(pszFilename, "GEOMEDIA:", strlen("GEOMEDIA:")) ) return NULL; if( !EQUALN(pszFilename,"WALK:", strlen("WALK:")) && !EQUAL(CPLGetExtension(pszFilename), "MDB") ) return NULL; #ifndef WIN32 // Try to register MDB Tools driver // // ODBCINST.INI NOTE: // This operation requires write access to odbcinst.ini file // located in directory pointed by ODBCINISYS variable. // Usually, it points to /etc, so non-root users can overwrite this // setting ODBCINISYS with location they have write access to, e.g.: // $ export ODBCINISYS=$HOME/etc // $ touch $ODBCINISYS/odbcinst.ini // // See: http://www.unixodbc.org/internals.html // if ( !InstallMdbDriver() ) { CPLError( CE_Warning, CPLE_AppDefined, "Unable to install MDB driver for ODBC, MDB access may not supported.\n" ); } else CPLDebug( "Walk", "MDB Tools driver installed successfully!"); #endif /* ndef WIN32 */ OGRWalkDataSource *poDS = new OGRWalkDataSource(); if( !poDS->Open( pszFilename, bUpdate ) ) { delete poDS; return NULL; } else return poDS; }
OGRDataSource *OGRGeomediaDriver::Open( const char * pszFilename, int bUpdate ) { OGRGeomediaDataSource *poDS; if( EQUALN(pszFilename, "WALK:", strlen("WALK:")) ) return NULL; if( EQUALN(pszFilename, "PGEO:", strlen("PGEO:")) ) return NULL; if( !EQUALN(pszFilename,"GEOMEDIA:",9) && !EQUAL(CPLGetExtension(pszFilename),"mdb") ) return NULL; /* Disabling the attempt to guess if a MDB file is a Geomedia database */ /* or not. See similar fix in PGeo driver for rationale. */ #if 0 if( !EQUALN(pszFilename,"GEOMEDIA:",9) && EQUAL(CPLGetExtension(pszFilename),"mdb") ) { VSILFILE* fp = VSIFOpenL(pszFilename, "rb"); if (!fp) return NULL; GByte* pabyHeader = (GByte*) CPLMalloc(100000); VSIFReadL(pabyHeader, 100000, 1, fp); VSIFCloseL(fp); /* Look for GAliasTable table */ const GByte pabyNeedle[] = { 'G', 0, 'A', 0, 'l', 0, 'i', 0, 'a', 0, 's', 0, 'T', 0, 'a', 0, 'b', 0, 'l', 0, 'e'}; int bFound = FALSE; for(int i=0;i<100000 - (int)sizeof(pabyNeedle);i++) { if (memcmp(pabyHeader + i, pabyNeedle, sizeof(pabyNeedle)) == 0) { bFound = TRUE; break; } } CPLFree(pabyHeader); if (!bFound) return NULL; } #endif #ifndef WIN32 // Try to register MDB Tools driver // // ODBCINST.INI NOTE: // This operation requires write access to odbcinst.ini file // located in directory pointed by ODBCINISYS variable. // Usually, it points to /etc, so non-root users can overwrite this // setting ODBCINISYS with location they have write access to, e.g.: // $ export ODBCINISYS=$HOME/etc // $ touch $ODBCINISYS/odbcinst.ini // // See: http://www.unixodbc.org/internals.html // if ( !InstallMdbDriver() ) { CPLError( CE_Warning, CPLE_AppDefined, "Unable to install MDB driver for ODBC, MDB access may not supported.\n" ); } else CPLDebug( "Geomedia", "MDB Tools driver installed successfully!"); #endif /* ndef WIN32 */ // Open data source poDS = new OGRGeomediaDataSource(); if( !poDS->Open( pszFilename, bUpdate, TRUE ) ) { delete poDS; return NULL; } else return poDS; }
OGRDataSource *OGRPGeoDriver::Open( const char * pszFilename, int bUpdate ) { if( STARTS_WITH_CI(pszFilename, "WALK:") ) return nullptr; if( STARTS_WITH_CI(pszFilename, "GEOMEDIA:") ) return nullptr; if( !STARTS_WITH_CI(pszFilename, "PGEO:") && !EQUAL(CPLGetExtension(pszFilename),"mdb") ) return nullptr; // Disabling the attempt to guess if a MDB file is a PGeo database // or not. The mention to GDB_GeomColumns might be quite far in // the/ file, which can cause misdetection. See // http://trac.osgeo.org/gdal/ticket/4498 This was initially meant // to know if a MDB should be opened by the PGeo or the Geomedia // driver. #if 0 if( !STARTS_WITH_CI(pszFilename, "PGEO:") && EQUAL(CPLGetExtension(pszFilename),"mdb") ) { VSILFILE* fp = VSIFOpenL(pszFilename, "rb"); if (!fp) return NULL; GByte* pabyHeader = (GByte*) CPLMalloc(100000); VSIFReadL(pabyHeader, 100000, 1, fp); VSIFCloseL(fp); /* Look for GDB_GeomColumns table */ const GByte pabyNeedle[] = { 'G', 0, 'D', 0, 'B', 0, '_', 0, 'G', 0, 'e', 0, 'o', 0, 'm', 0, 'C', 0, 'o', 0, 'l', 0, 'u', 0, 'm', 0, 'n', 0, 's' }; int bFound = FALSE; for(int i=0;i<100000 - (int)sizeof(pabyNeedle);i++) { if (memcmp(pabyHeader + i, pabyNeedle, sizeof(pabyNeedle)) == 0) { bFound = TRUE; break; } } CPLFree(pabyHeader); if (!bFound) return NULL; } #endif #ifndef WIN32 // Try to register MDB Tools driver // // ODBCINST.INI NOTE: // This operation requires write access to odbcinst.ini file // located in directory pointed by ODBCINISYS variable. // Usually, it points to /etc, so non-root users can overwrite this // setting ODBCINISYS with location they have write access to, e.g.: // $ export ODBCINISYS=$HOME/etc // $ touch $ODBCINISYS/odbcinst.ini // // See: http://www.unixodbc.org/internals.html // if ( !InstallMdbDriver() ) { CPLError( CE_Warning, CPLE_AppDefined, "Unable to install MDB driver for ODBC, MDB access may not supported.\n" ); } else CPLDebug( "PGeo", "MDB Tools driver installed successfully!"); #endif /* ndef WIN32 */ // Open data source OGRPGeoDataSource *poDS = new OGRPGeoDataSource(); if( !poDS->Open( pszFilename, bUpdate, TRUE ) ) { delete poDS; return nullptr; } else return poDS; }