diff --git a/include/osgDB/FileNameUtils b/include/osgDB/FileNameUtils index 7f9310cb0..6abd54d1b 100644 --- a/include/osgDB/FileNameUtils +++ b/include/osgDB/FileNameUtils @@ -20,16 +20,27 @@ namespace osgDB { +/** Gets the parent path from full name (Ex: /a/b/c.Ext => /a/b). */ extern OSGDB_EXPORT std::string getFilePath(const std::string& filename); +/** Gets the extension without dot (Ex: /a/b/c.Ext => Ext). */ extern OSGDB_EXPORT std::string getFileExtension(const std::string& filename); +/** Gets the extension including dot (Ex: /a/b/c.Ext => .Ext). */ extern OSGDB_EXPORT std::string getFileExtensionIncludingDot(const std::string& filename); +/** Gets the lowercase extension without dot (Ex: /a/b/c.Ext => ext). */ extern OSGDB_EXPORT std::string getLowerCaseFileExtension(const std::string& filename); +/** Gets file name with extension (Ex: /a/b/c.Ext => c.Ext). */ extern OSGDB_EXPORT std::string getSimpleFileName(const std::string& fileName); +/** Gets file path without last extension (Ex: /a/b/c.Ext => /a/b/c ; file.ext1.ext2 => file.ext1). */ extern OSGDB_EXPORT std::string getNameLessExtension(const std::string& fileName); +/** Gets file path without \b all extensions (Ex: /a/b/c.Ext => /a/b/c ; file.ext1.ext2 => file). */ +extern OSGDB_EXPORT std::string getNameLessAllExtensions(const std::string& fileName); +/** Gets file name without last extension (Ex: /a/b/c.Ext => c ; file.ext1.ext2 => file.ext1). */ extern OSGDB_EXPORT std::string getStrippedName(const std::string& fileName); +/** Converts forward slashes (/) to back slashes (\). */ extern OSGDB_EXPORT std::string convertFileNameToWindowsStyle(const std::string& fileName); +/** Converts back slashes (\) to forward slashes (/). */ extern OSGDB_EXPORT std::string convertFileNameToUnixStyle(const std::string& fileName); extern OSGDB_EXPORT std::string convertToLowerCase(const std::string& fileName); diff --git a/src/osgDB/FileNameUtils.cpp b/src/osgDB/FileNameUtils.cpp index 8499d7a22..ad88090e8 100644 --- a/src/osgDB/FileNameUtils.cpp +++ b/src/osgDB/FileNameUtils.cpp @@ -138,14 +138,24 @@ 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('.'); - 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