From 48fe06fec3a6824df69f9e9441e335facc61162f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 22 Sep 2008 14:46:54 +0000 Subject: [PATCH] Added getExtensionIncludingDot to provide more efficient handling of extensions --- include/osgDB/FileNameUtils | 1 + src/osgDB/FileNameUtils.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/osgDB/FileNameUtils b/include/osgDB/FileNameUtils index 944101a1a..234bec22f 100644 --- a/include/osgDB/FileNameUtils +++ b/include/osgDB/FileNameUtils @@ -22,6 +22,7 @@ namespace osgDB { extern OSGDB_EXPORT std::string getFilePath(const std::string& filename); extern OSGDB_EXPORT std::string getFileExtension(const std::string& filename); +extern OSGDB_EXPORT std::string getFileExtensionIncludingDot(const std::string& filename); extern OSGDB_EXPORT std::string getLowerCaseFileExtension(const std::string& filename); extern OSGDB_EXPORT std::string getSimpleFileName(const std::string& fileName); extern OSGDB_EXPORT std::string getNameLessExtension(const std::string& fileName); diff --git a/src/osgDB/FileNameUtils.cpp b/src/osgDB/FileNameUtils.cpp index b8cc4c1c2..605fc94dc 100644 --- a/src/osgDB/FileNameUtils.cpp +++ b/src/osgDB/FileNameUtils.cpp @@ -66,6 +66,13 @@ std::string osgDB::getFileExtension(const std::string& fileName) return std::string(fileName.begin()+dot+1,fileName.end()); } +std::string osgDB::getFileExtensionIncludingDot(const std::string& fileName) +{ + std::string::size_type dot = fileName.find_last_of('.'); + if (dot==std::string::npos) return std::string(""); + return std::string(fileName.begin()+dot,fileName.end()); +} + std::string osgDB::convertFileNameToWindowsStyle(const std::string& fileName) { std::string new_fileName(fileName);