diff --git a/include/osgDB/FileNameUtils b/include/osgDB/FileNameUtils index c842d0066..c963ad799 100644 --- a/include/osgDB/FileNameUtils +++ b/include/osgDB/FileNameUtils @@ -41,6 +41,13 @@ extern OSGDB_EXPORT bool containsServerAddress(const std::string& filename); extern OSGDB_EXPORT std::string getServerAddress(const std::string& filename); extern OSGDB_EXPORT std::string getServerFileName(const std::string& filename); +/** Concatenates two paths */ +extern OSGDB_EXPORT std::string concatPaths(const std::string& left, const std::string& right); + +/** Removes .. and . dirs in a path */ +extern OSGDB_EXPORT std::string getRealPath(const std::string& path); + + } #endif diff --git a/src/osgDB/FileNameUtils.cpp b/src/osgDB/FileNameUtils.cpp index 581f1c033..00dfec5ca 100644 --- a/src/osgDB/FileNameUtils.cpp +++ b/src/osgDB/FileNameUtils.cpp @@ -202,17 +202,43 @@ std::string osgDB::getServerFileName(const std::string& filename) return filename; } +std::string osgDB::concatPaths(const std::string& left, const std::string& right) +{ +#ifdef WIN32 + const char delimiterNative = '\\'; + const char delimiterForeign = '/'; +#else + const char delimiterNative = '/'; + const char delimiterForeign = '\\'; +#endif -// // here a little test I wrote to make sure a couple of the above methods are -// // working fine. -// void test() -// { -// std::string test("/here/we/are.exe"); -// std::string test2("\\there\\you\\go.dll"); -// std::cout << "getFilePath("<empty() ? filename : *itr + '/'+ filename; + std::string path = itr->empty() ? filename : concatPaths(*itr, filename); + + path = getRealPath(path); + osg::notify(osg::DEBUG_INFO) << "FindFileInPath() : trying " << path << " ...\n"; if(fileExists(path)) {