Fixed a recently introduced crash in the flt plugin which was happen when a
std::string was be be set with NULL char*. Also added support for stripping the filename from its original path, inside the osgDB::findFile function.
This commit is contained in:
parent
c66557087d
commit
8df894924c
@ -150,7 +150,18 @@ static char *findFileInPath( const char *_file, const char * filePath )
|
||||
|
||||
char *osgDB::findFile( const char *file )
|
||||
{
|
||||
return findFileInPath( file, s_filePath );
|
||||
if (!file) return NULL;
|
||||
|
||||
char* newFileName = findFileInPath( file, s_filePath );
|
||||
if (newFileName) return newFileName;
|
||||
|
||||
|
||||
// need to check here to see if file has a path on it.
|
||||
|
||||
// now strip the file of an previous path if one exists.
|
||||
std::string simpleFileName = getSimpleFileName(file);
|
||||
newFileName = findFileInPath( simpleFileName.c_str(), s_filePath );
|
||||
return newFileName;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -91,9 +91,9 @@ Record* FltFile::readFile(const std::string& fileName)
|
||||
if (!fin.open(fileName))
|
||||
{
|
||||
// ok havn't found file, resort to using findFile...
|
||||
std::string newFileName = osgDB::findFile(fileName.c_str());
|
||||
char* newFileName = osgDB::findFile(fileName.c_str());
|
||||
|
||||
if (newFileName.empty()) return NULL;
|
||||
if (!newFileName) return NULL;
|
||||
if (!fin.open(newFileName)) return NULL;
|
||||
}
|
||||
|
||||
|
@ -67,10 +67,10 @@ bool FileInput::open(const std::string& fileName)
|
||||
if (_file == NULL)
|
||||
{
|
||||
// ok havn't found file, resort to using findFile...
|
||||
std::string newFileName = osgDB::findFile(fileName.c_str());
|
||||
if (newFileName.empty()) return false;
|
||||
char* newFileName = osgDB::findFile(fileName.c_str());
|
||||
|
||||
_file=::fopen( fileName.c_str(), "rb");
|
||||
if (!newFileName) return false;
|
||||
_file=::fopen( newFileName, "rb");
|
||||
if (_file == NULL) return false;
|
||||
}
|
||||
_eof = false;
|
||||
|
Loading…
Reference in New Issue
Block a user