From b78ad29429dbfff6fa487799f86574dc3f18b64f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 29 Apr 2011 16:50:45 +0000 Subject: [PATCH] Improved the handling of different combinations of slashes and dirNames. --- src/osgPlugins/osga/OSGA_Archive.cpp | 41 ++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/osgPlugins/osga/OSGA_Archive.cpp b/src/osgPlugins/osga/OSGA_Archive.cpp index 49881c48a..79886ef2e 100644 --- a/src/osgPlugins/osga/OSGA_Archive.cpp +++ b/src/osgPlugins/osga/OSGA_Archive.cpp @@ -527,6 +527,16 @@ bool OSGA_Archive::getFileNames(FileNameList& fileNameList) const osgDB::DirectoryContents OSGA_Archive::getDirectoryContents(const std::string& dirName) const { osgDB::DirectoryContents files; + if (dirName.empty() || dirName==".") + { + getFileNames(files); + return files; + } + + bool dirNameHasTrailingSlash = false; + char d = dirName[dirName.size()-1]; + if (d=='\\' || d=='/') dirNameHasTrailingSlash = true; + for(FileNamePositionMap::const_iterator itr=_indexMap.begin(); itr!=_indexMap.end(); ++itr) @@ -548,21 +558,30 @@ osgDB::DirectoryContents OSGA_Archive::getDirectoryContents(const std::string& d if (i==dirName.size()) { - // directory name matched, but need to make sure a trailing filename exists - // and to skip over any immediate slashes - char f = filename[i]; - - // check for slash - if (f=='\\' || f=='/') + bool directoryMatched = false; + if (!dirNameHasTrailingSlash) { - // found slash, now need to skip over it. - ++i; - if (i