void CPLFinderClean() { FindFileTLS* pTLSData = CPLGetFindFileTLS(); CPLFindFileFreeTLS(pTLSData); CPLSetTLS( CTLS_FINDFILE, NULL, FALSE ); }
static FindFileTLS* CPLFinderInit() { FindFileTLS* pTLSData = CPLGetFindFileTLS(); if( pTLSData != NULL && !pTLSData->bFinderInitialized ) { pTLSData->bFinderInitialized = TRUE; CPLPushFileFinder( CPLDefaultFindFile ); CPLPushFinderLocation( "." ); if( CPLGetConfigOption( "GDAL_DATA", NULL ) != NULL ) { CPLPushFinderLocation( CPLGetConfigOption( "GDAL_DATA", NULL ) ); } else { #ifdef GDAL_PREFIX #ifdef MACOSX_FRAMEWORK CPLPushFinderLocation( GDAL_PREFIX "/Resources/gdal" ); #else CPLPushFinderLocation( GDAL_PREFIX "/share/gdal" ); #endif #else CPLPushFinderLocation( "/usr/local/share/gdal" ); #endif } } return pTLSData; }
static FindFileTLS* CPLFinderInit() { FindFileTLS* pTLSData = CPLGetFindFileTLS(); if( pTLSData != nullptr && !pTLSData->bFinderInitialized ) { pTLSData->bFinderInitialized = true; CPLPushFileFinder( CPLDefaultFindFile ); CPLPushFinderLocation( "." ); if( CPLGetConfigOption( "GDAL_DATA", nullptr ) != nullptr ) { CPLPushFinderLocation( CPLGetConfigOption( "GDAL_DATA", nullptr ) ); } else { #ifdef INST_DATA CPLPushFinderLocation( INST_DATA ); #endif #ifdef GDAL_PREFIX #ifdef MACOSX_FRAMEWORK CPLPushFinderLocation( GDAL_PREFIX "/Resources/gdal" ); #else CPLPushFinderLocation( GDAL_PREFIX "/share/gdal" ); #endif #endif } } return pTLSData; }
/** CPLFinderClean */ void CPLFinderClean() { FindFileTLS* pTLSData = CPLGetFindFileTLS(); CPLFindFileFreeTLS(pTLSData); int bMemoryError = FALSE; CPLSetTLSWithFreeFuncEx( CTLS_FINDFILE, nullptr, nullptr, &bMemoryError ); // TODO: if( bMemoryError ) {} }
void CPLFinderClean() { FindFileTLS* pTLSData = CPLGetFindFileTLS(); if( pTLSData->bFinderInitialized ) { while( pTLSData->papszFinderLocations != NULL ) CPLPopFinderLocation(); while( CPLPopFileFinder() != NULL ) {} pTLSData->bFinderInitialized = FALSE; } }
const char *CPLDefaultFindFile( const char * /* pszClass */, const char *pszBasename ) { FindFileTLS* pTLSData = CPLGetFindFileTLS(); if( pTLSData == NULL ) return NULL; const int nLocations = CSLCount( pTLSData->papszFinderLocations ); for( int i = nLocations-1; i >= 0; i-- ) { const char *pszResult = CPLFormFilename( pTLSData->papszFinderLocations[i], pszBasename, NULL ); VSIStatBufL sStat; if( VSIStatL( pszResult, &sStat ) == 0 ) return pszResult; } return NULL; }
const char *CPLDefaultFindFile( const char *pszClass, const char *pszBasename ) { FindFileTLS* pTLSData = CPLGetFindFileTLS(); int i, nLocations = CSLCount( pTLSData->papszFinderLocations ); (void) pszClass; for( i = nLocations-1; i >= 0; i-- ) { const char *pszResult; VSIStatBuf sStat; pszResult = CPLFormFilename( pTLSData->papszFinderLocations[i], pszBasename, NULL ); if( VSIStat( pszResult, &sStat ) == 0 ) return pszResult; } return NULL; }