~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to port/cpl_findfile.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: cpl_findfile.cpp 17143 2009-05-28 18:26:05Z rouault $
 
2
 * $Id: cpl_findfile.cpp 20089 2010-07-17 20:42:03Z rouault $
3
3
 *
4
4
 * Project:  CPL - Common Portability Library
5
5
 * Purpose:  Generic data file location finder, with application hooking.
31
31
#include "cpl_string.h"
32
32
#include "cpl_multiproc.h"
33
33
 
34
 
CPL_CVSID("$Id: cpl_findfile.cpp 17143 2009-05-28 18:26:05Z rouault $");
 
34
CPL_CVSID("$Id: cpl_findfile.cpp 20089 2010-07-17 20:42:03Z rouault $");
35
35
 
36
36
typedef struct
37
37
{
43
43
 
44
44
 
45
45
/************************************************************************/
 
46
/*                      CPLFindFileDeinitTLS()                          */
 
47
/************************************************************************/
 
48
 
 
49
static void CPLPopFinderLocationInternal(FindFileTLS* pTLSData);
 
50
static CPLFileFinder CPLPopFileFinderInternal(FindFileTLS* pTLSData);
 
51
 
 
52
static void CPLFindFileFreeTLS(void* pData)
 
53
{
 
54
    FindFileTLS* pTLSData = (FindFileTLS*) pData;
 
55
    if( pTLSData->bFinderInitialized )
 
56
    {
 
57
        while( pTLSData->papszFinderLocations != NULL )
 
58
            CPLPopFinderLocationInternal(pTLSData);
 
59
        while( CPLPopFileFinderInternal(pTLSData) != NULL ) {}
 
60
 
 
61
        pTLSData->bFinderInitialized = FALSE;
 
62
    }
 
63
    CPLFree(pTLSData);
 
64
}
 
65
 
 
66
/************************************************************************/
46
67
/*                       CPLGetFindFileTLS()                            */
47
68
/************************************************************************/
48
69
 
53
74
    if (pTLSData == NULL)
54
75
    {
55
76
        pTLSData = (FindFileTLS*) CPLCalloc(1, sizeof(FindFileTLS));
56
 
        CPLSetTLS( CTLS_FINDFILE, pTLSData, TRUE );
 
77
        CPLSetTLSWithFreeFunc( CTLS_FINDFILE, pTLSData, CPLFindFileFreeTLS );
57
78
    }
58
79
    return pTLSData;
59
80
}
83
104
  #ifdef MACOSX_FRAMEWORK
84
105
            CPLPushFinderLocation( GDAL_PREFIX "/Resources/gdal" );
85
106
  #else
86
 
            CPLPushFinderLocation( GDAL_PREFIX "/share/gdal/1.7" );
 
107
            CPLPushFinderLocation( GDAL_PREFIX "/share/gdal/1.9" );
87
108
  #endif
88
109
#else
89
110
            CPLPushFinderLocation( "/usr/local/share/gdal" );
101
122
 
102
123
{
103
124
    FindFileTLS* pTLSData = CPLGetFindFileTLS();
104
 
    if( pTLSData->bFinderInitialized )
105
 
    {
106
 
        while( pTLSData->papszFinderLocations != NULL )
107
 
            CPLPopFinderLocation();
108
 
        while( CPLPopFileFinder() != NULL ) {}
109
 
 
110
 
        pTLSData->bFinderInitialized = FALSE;
111
 
    }
 
125
    CPLFindFileFreeTLS(pTLSData);
 
126
    CPLSetTLS( CTLS_FINDFILE, NULL, FALSE );
112
127
}
113
128
 
114
129
/************************************************************************/
180
195
/*                          CPLPopFileFinder()                          */
181
196
/************************************************************************/
182
197
 
183
 
CPLFileFinder CPLPopFileFinder()
 
198
CPLFileFinder CPLPopFileFinderInternal(FindFileTLS* pTLSData)
184
199
 
185
200
{
186
201
    CPLFileFinder pfnReturn;
187
202
 
188
 
    FindFileTLS* pTLSData = CPLFinderInit();
189
 
 
190
203
    if( pTLSData->nFileFinders == 0 )
191
204
        return NULL;
192
205
 
201
214
    return pfnReturn;
202
215
}
203
216
 
 
217
CPLFileFinder CPLPopFileFinder()
 
218
 
 
219
{
 
220
    return CPLPopFileFinderInternal(CPLFinderInit());
 
221
}
 
222
 
204
223
/************************************************************************/
205
224
/*                       CPLPushFinderLocation()                        */
206
225
/************************************************************************/
219
238
/*                       CPLPopFinderLocation()                         */
220
239
/************************************************************************/
221
240
 
222
 
void CPLPopFinderLocation()
 
241
static void CPLPopFinderLocationInternal(FindFileTLS* pTLSData)
223
242
 
224
243
{
225
244
    int      nCount;
226
245
 
227
 
    FindFileTLS* pTLSData = CPLFinderInit();
228
 
 
229
246
    if( pTLSData->papszFinderLocations == NULL )
230
247
        return;
231
248
 
242
259
        pTLSData->papszFinderLocations = NULL;
243
260
    }
244
261
}
 
262
 
 
263
void CPLPopFinderLocation()
 
264
{
 
265
    CPLPopFinderLocationInternal(CPLFinderInit());
 
266
}