MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLDefaultFindFile

Function CPLDefaultFindFile

port/cpl_findfile.cpp:132–157  ·  view source on GitHub ↗

CPLDefaultFindFile */

Source from the content-addressed store, hash-verified

130
131/** CPLDefaultFindFile */
132const char *CPLDefaultFindFile(const char *pszClass, const char *pszBasename)
133
134{
135 FindFileTLS *pTLSData = CPLGetFindFileTLS();
136 if (pTLSData == nullptr)
137 return nullptr;
138 const int nLocations = CSLCount(pTLSData->papszFinderLocations);
139
140 for (int i = nLocations - 1; i >= 0; i--)
141 {
142 const std::string osResult = CPLFormFilenameSafe(
143 pTLSData->papszFinderLocations[i], pszBasename, nullptr);
144
145 VSIStatBufL sStat;
146 if (VSIStatL(osResult.c_str(), &sStat) == 0)
147 return CPLSPrintf("%s", osResult.c_str());
148 }
149
150 if (EQUAL(pszClass, "gdal") && !CPLGetConfigOption("GDAL_DATA", nullptr))
151 {
152 CPLError(CE_Warning, CPLE_FileIO,
153 "Cannot find %s (GDAL_DATA is not defined)", pszBasename);
154 }
155
156 return nullptr;
157}
158
159/************************************************************************/
160/* CPLFindFile() */

Callers

nothing calls this directly

Calls 8

CPLGetFindFileTLSFunction · 0.85
CSLCountFunction · 0.85
CPLFormFilenameSafeFunction · 0.85
VSIStatLFunction · 0.85
CPLSPrintfFunction · 0.85
CPLErrorFunction · 0.85
EQUALFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected