#658: better bugfix for findDataFile issue

Fixes the more basic probelm of "SGModelLib::findDataFile" resolving an
empty file name to the fgdata (directory) path. findData_File_ should
never return a _directory_ path, only valid _file_ names.
This commit is contained in:
ThorstenB
2012-02-11 10:55:13 +01:00
parent 2a0e9d31e1
commit 811f156ad1
2 changed files with 8 additions and 9 deletions

View File

@@ -216,14 +216,11 @@ TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
if (pImage)
{
imageName = pImage->getStringValue();
if (!imageName.empty())
absFileName = SGModelLib::findDataFile(imageName, options);
if (absFileName.empty())
{
absFileName = SGModelLib::findDataFile(imageName, options);
if (absFileName.empty())
{
SG_LOG(SG_INPUT, SG_ALERT, "Texture file not found: '"
<< imageName << "'");
}
SG_LOG(SG_INPUT, SG_ALERT, "Texture file not found: '"
<< imageName << "'");
}
}

View File

@@ -68,11 +68,13 @@ std::string SGModelLib::findDataFile(const std::string& file,
const osgDB::ReaderWriter::Options* opts,
SGPath currentPath)
{
if (file.empty())
return file;
SGPath p = ResourceManager::instance()->findPath(file, currentPath);
if (p.exists()) {
if (p.exists()&&p.isFile()) {
return p.str();
}
// finally hand on to standard OSG behaviour
return osgDB::findDataFile(file, opts);
}