Changeset 11184
- Timestamp:
- 03/10/10 12:40:17 (3 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 2 modified
-
include/osgDB/FileNameUtils (modified) (1 diff)
-
src/osgDB/FileNameUtils.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgDB/FileNameUtils
r9884 r11184 21 21 namespace osgDB { 22 22 23 /** Gets the parent path from full name (Ex: /a/b/c.Ext => /a/b). */ 23 24 extern OSGDB_EXPORT std::string getFilePath(const std::string& filename); 25 /** Gets the extension without dot (Ex: /a/b/c.Ext => Ext). */ 24 26 extern OSGDB_EXPORT std::string getFileExtension(const std::string& filename); 27 /** Gets the extension including dot (Ex: /a/b/c.Ext => .Ext). */ 25 28 extern OSGDB_EXPORT std::string getFileExtensionIncludingDot(const std::string& filename); 29 /** Gets the lowercase extension without dot (Ex: /a/b/c.Ext => ext). */ 26 30 extern OSGDB_EXPORT std::string getLowerCaseFileExtension(const std::string& filename); 31 /** Gets file name with extension (Ex: /a/b/c.Ext => c.Ext). */ 27 32 extern OSGDB_EXPORT std::string getSimpleFileName(const std::string& fileName); 33 /** Gets file path without last extension (Ex: /a/b/c.Ext => /a/b/c ; file.ext1.ext2 => file.ext1). */ 28 34 extern OSGDB_EXPORT std::string getNameLessExtension(const std::string& fileName); 35 /** Gets file path without \b all extensions (Ex: /a/b/c.Ext => /a/b/c ; file.ext1.ext2 => file). */ 36 extern OSGDB_EXPORT std::string getNameLessAllExtensions(const std::string& fileName); 37 /** Gets file name without last extension (Ex: /a/b/c.Ext => c ; file.ext1.ext2 => file.ext1). */ 29 38 extern OSGDB_EXPORT std::string getStrippedName(const std::string& fileName); 30 39 31 40 41 /** Converts forward slashes (/) to back slashes (\). */ 32 42 extern OSGDB_EXPORT std::string convertFileNameToWindowsStyle(const std::string& fileName); 43 /** Converts back slashes (\) to forward slashes (/). */ 33 44 extern OSGDB_EXPORT std::string convertFileNameToUnixStyle(const std::string& fileName); 34 45 extern OSGDB_EXPORT std::string convertToLowerCase(const std::string& fileName); -
OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp
r11171 r11184 139 139 std::string osgDB::getNameLessExtension(const std::string& fileName) 140 140 { 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; 141 std::string::size_type dot = fileName.find_last_of('.'); 142 std::string::size_type slash = fileName.find_last_of("/\\"); // Finds forward slash *or* back slash 143 if (dot==std::string::npos || (slash!=std::string::npos && dot<slash)) return fileName; 145 144 return std::string(fileName.begin(),fileName.begin()+dot); 146 145 } 147 146 147 148 // strip all extensions from the filename. 149 std::string osgDB::getNameLessAllExtensions(const std::string& fileName) 150 { 151 // Finds start serach position: from last slash, or the begining of the string if none found 152 std::string::size_type startPos = fileName.find_last_of("/\\"); // Finds forward slash *or* back slash 153 if (startPos == std::string::npos) startPos = 0; 154 std::string::size_type dot = fileName.find_first_of('.', startPos); // Finds *FIRST* dot from start pos 155 if (dot==std::string::npos) return fileName; 156 return std::string(fileName.begin(),fileName.begin()+dot); 157 } 148 158 149 159 std::string osgDB::getStrippedName(const std::string& fileName)
