| 292 | | return findDataFile(filename,static_cast<ReaderWriter::Options*>(0),caseSensitivity); |
| 293 | | } |
| 294 | | |
| 295 | | OSGDB_EXPORT std::string osgDB::findDataFile(const std::string& filename,const ReaderWriter::Options* options, CaseSensitivity caseSensitivity) |
| 296 | | { |
| 297 | | if (filename.empty()) return filename; |
| 298 | | |
| 299 | | if(fileExists(filename)) |
| 300 | | { |
| 301 | | osg::notify(osg::DEBUG_INFO) << "FindFileInPath(" << filename << "): returning " << filename << std::endl; |
| 302 | | return filename; |
| 303 | | } |
| 304 | | |
| 305 | | std::string fileFound; |
| 306 | | |
| 307 | | if (options && !options->getDatabasePathList().empty()) |
| 308 | | { |
| 309 | | fileFound = findFileInPath(filename, options->getDatabasePathList(), caseSensitivity); |
| 310 | | if (!fileFound.empty()) return fileFound; |
| 311 | | } |
| 312 | | |
| 313 | | const FilePathList& filepath = Registry::instance()->getDataFilePathList(); |
| 314 | | if (!filepath.empty()) |
| 315 | | { |
| 316 | | fileFound = findFileInPath(filename, filepath,caseSensitivity); |
| 317 | | if (!fileFound.empty()) return fileFound; |
| 318 | | } |
| 319 | | |
| 320 | | |
| 321 | | // if a directory is included in the filename, get just the (simple) filename itself and try that |
| 322 | | std::string simpleFileName = getSimpleFileName(filename); |
| 323 | | if (simpleFileName!=filename) |
| 324 | | { |
| 325 | | |
| 326 | | if(fileExists(simpleFileName)) |
| 327 | | { |
| 328 | | osg::notify(osg::DEBUG_INFO) << "FindFileInPath(" << filename << "): returning " << filename << std::endl; |
| 329 | | return simpleFileName; |
| 330 | | } |
| 331 | | |
| 332 | | if (options && !options->getDatabasePathList().empty()) |
| 333 | | { |
| 334 | | fileFound = findFileInPath(simpleFileName, options->getDatabasePathList(), caseSensitivity); |
| 335 | | if (!fileFound.empty()) return fileFound; |
| 336 | | } |
| 337 | | |
| 338 | | if (!filepath.empty()) |
| 339 | | { |
| 340 | | fileFound = findFileInPath(simpleFileName, filepath,caseSensitivity); |
| 341 | | if (!fileFound.empty()) return fileFound; |
| 342 | | } |
| 343 | | |
| 344 | | } |
| 345 | | |
| 346 | | // return empty string. |
| 347 | | return std::string(); |
| | 292 | return findDataFile(filename,static_cast<Options*>(0),caseSensitivity); |
| | 293 | } |
| | 294 | |
| | 295 | OSGDB_EXPORT std::string osgDB::findDataFile(const std::string& filename,const Options* options, CaseSensitivity caseSensitivity) |
| | 296 | { |
| | 297 | return Registry::instance()->findDataFile(filename, options, caseSensitivity); |
| 352 | | if (filename.empty()) |
| 353 | | return filename; |
| 354 | | |
| 355 | | const FilePathList& filepath = Registry::instance()->getLibraryFilePathList(); |
| 356 | | |
| 357 | | std::string fileFound = findFileInPath(filename, filepath,caseSensitivity); |
| 358 | | if (!fileFound.empty()) |
| 359 | | return fileFound; |
| 360 | | |
| 361 | | if(fileExists(filename)) |
| 362 | | { |
| 363 | | osg::notify(osg::DEBUG_INFO) << "FindFileInPath(" << filename << "): returning " << filename << std::endl; |
| 364 | | return filename; |
| 365 | | } |
| 366 | | |
| 367 | | // if a directory is included in the filename, get just the (simple) filename itself and try that |
| 368 | | std::string simpleFileName = getSimpleFileName(filename); |
| 369 | | if (simpleFileName!=filename) |
| 370 | | { |
| 371 | | std::string fileFound = findFileInPath(simpleFileName, filepath,caseSensitivity); |
| 372 | | if (!fileFound.empty()) return fileFound; |
| 373 | | } |
| 374 | | |
| 375 | | // failed return empty string. |
| 376 | | return std::string(); |
| | 302 | return Registry::instance()->findLibraryFile(filename, osgDB::Registry::instance()->getOptions(), caseSensitivity); |