Show
Ignore:
Timestamp:
03/05/10 16:10:34 (5 years ago)
Author:
robert
Message:

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."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp

    r10818 r11169  
    139139std::string osgDB::getNameLessExtension(const std::string& fileName) 
    140140{ 
    141     std::string::size_type dot = fileName.find_last_of('.'); 
    142     if (dot==std::string::npos) return fileName; 
     141    std::string::size_type dot = fileName.find_last_of('.');  
     142    std::string::size_type back_slash = fileName.find_last_of('\\'); 
     143    std::string::size_type slash = fileName.find_last_of('/');  
     144    if (dot==std::string::npos || (dot<back_slash && dot<slash)) return fileName; 
    143145    return std::string(fileName.begin(),fileName.begin()+dot); 
    144146}