From dd0c29d19bbf73a2a795dab0001d47359ada6330 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 11 Feb 2005 09:58:30 +0000 Subject: [PATCH] Added new utilities for handling different '/' and '\' entries. --- include/osgDB/FileNameUtils | 7 ++++++ src/osgDB/FileNameUtils.cpp | 50 +++++++++++++++++++++++++++++++++++++ src/osgDB/FileUtils.cpp | 3 +++ 3 files changed, 60 insertions(+) diff --git a/include/osgDB/FileNameUtils b/include/osgDB/FileNameUtils index 9ffc515ed..72a36f510 100644 --- a/include/osgDB/FileNameUtils +++ b/include/osgDB/FileNameUtils @@ -27,6 +27,13 @@ extern OSGDB_EXPORT std::string getSimpleFileName(const std::string& fileName); extern OSGDB_EXPORT std::string getNameLessExtension(const std::string& fileName); extern OSGDB_EXPORT std::string getStrippedName(const std::string& fileName); + +extern OSGDB_EXPORT std::string convertFileNameToWindowsStyle(const std::string& fileName); +extern OSGDB_EXPORT std::string convertFileNameToUnixStyle(const std::string& fileName); + +extern OSGDB_EXPORT bool isFileNameNativeStyle(const std::string& fileName); +extern OSGDB_EXPORT std::string convertFileNameToNativeStyle(const std::string& fileName); + extern OSGDB_EXPORT bool equalCaseInsensitive(const std::string& lhs,const std::string& rhs); extern OSGDB_EXPORT bool equalCaseInsensitive(const std::string& lhs,const char* rhs); diff --git a/src/osgDB/FileNameUtils.cpp b/src/osgDB/FileNameUtils.cpp index 526bc8374..f5a7c891f 100644 --- a/src/osgDB/FileNameUtils.cpp +++ b/src/osgDB/FileNameUtils.cpp @@ -20,6 +20,8 @@ using std::strlen; #endif +#include + using namespace std; std::string osgDB::getFilePath(const std::string& fileName) @@ -57,6 +59,54 @@ std::string osgDB::getFileExtension(const std::string& fileName) return std::string(fileName.begin()+dot+1,fileName.end()); } +std::string osgDB::convertFileNameToWindowsStyle(const std::string& fileName) +{ + std::string new_fileName(fileName); + + std::string::size_type slash = 0; + while( (slash=new_fileName.find_first_of('/',slash)) != std::string::npos) + { + new_fileName[slash]='\\'; + } + return new_fileName; +} + +std::string osgDB::convertFileNameToUnixStyle(const std::string& fileName) +{ + osg::notify(osg::NOTICE)<<"convertFileNameToUnixStyle("<