Ejemplo n.º 1
0
void CPLFinderClean()

{
    FindFileTLS* pTLSData = CPLGetFindFileTLS();
    CPLFindFileFreeTLS(pTLSData);
    CPLSetTLS( CTLS_FINDFILE, NULL, FALSE );
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
/** CPLFinderClean */
void CPLFinderClean()

{
    FindFileTLS* pTLSData = CPLGetFindFileTLS();
    CPLFindFileFreeTLS(pTLSData);
    int bMemoryError = FALSE;
    CPLSetTLSWithFreeFuncEx( CTLS_FINDFILE, nullptr, nullptr, &bMemoryError );
    // TODO: if( bMemoryError ) {}
}
Ejemplo n.º 5
0
void CPLFinderClean()

{
    FindFileTLS* pTLSData = CPLGetFindFileTLS();
    if( pTLSData->bFinderInitialized )
    {
        while( pTLSData->papszFinderLocations != NULL )
            CPLPopFinderLocation();
        while( CPLPopFileFinder() != NULL ) {}

        pTLSData->bFinderInitialized = FALSE;
    }
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
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;
}