From Sukender, "Here is a tiny fix for getNameLessExtension(). It does now check for the presence of slashes ('/' and '\') to avoid changing the string when having a dot in a directory.

Old behaviour: "abc.d/filename_no_ext" -> "abc"
New behaviour: "abc.d/filename_no_ext" -> "abc.d/filename_no_ext"

Attached file is against rev. 11158."
This commit is contained in:
Robert Osfield
2010-03-05 15:10:34 +00:00
parent 073a60b2a1
commit e77fafcd98

View File

@@ -138,8 +138,10 @@ std::string osgDB::convertToLowerCase(const std::string& str)
// strip one level of extension from the filename.
std::string osgDB::getNameLessExtension(const std::string& fileName)
{
std::string::size_type dot = fileName.find_last_of('.');
if (dot==std::string::npos) return fileName;
std::string::size_type dot = fileName.find_last_of('.');
std::string::size_type back_slash = fileName.find_last_of('\\');
std::string::size_type slash = fileName.find_last_of('/');
if (dot==std::string::npos || (dot<back_slash && dot<slash)) return fileName;
return std::string(fileName.begin(),fileName.begin()+dot);
}