Hi Bradley,
Rather than dive in right away and merge you submission I thought I'd
prep the ground for it - first up added your suggested methods to
osgDB::Archive. I have also implemented these methods in the osga
plugin, although as yet I have only compiled then and will need
obviously need to test them properly by adding extra checks to the
osgarchive example. I have run out working week so will have to leave
this to others or for another day.
I have now checked these changes into svn/trunk, could you please
update you submission to use the osgDB::Archive as your
ArchiveExtended is no longer required. I would also like you to
review my implementation of OSGA_Archive::getDirectoryContents(..) as
I believe this is the type of functionality you intended, but I've
added handling of the possibility of different slashes being used in
the archive vs
calling functions directory name. The implementation is below (also
in svn/trunk's src/osgPlugins/osga).
It occurred to me that would could probably implement the
getDirectoryContents() method directly in the
base class if we change this function to use the getFileNames()
function to get all the filenames from the
underlying implementation. This wouldn't be quite as computationally
efficient, but would avoid the potential
for the implementations to diverge in their interpretation of how they
are meant to work. Another possible approproach would be to put a
helper method into base class to help with the identification of
contenders for a directory name match.
Thoughts?
Robert.
-- Implementation of OSGGA_Archive::getDirectoryContents(const
std::string&) 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)
{
const std::string& filename = itr->first;
if (filename.size()>dirName.size())
{
// check for match of directory name while accounting for potential
// differences in types of slashes
unsigned int i=0;
for(; i<dirName.size(); ++i)
{
char f = filename[i];
char d = dirName[i];
if (f=='\\') f='/';
if (d=='\\') d='/';
if (f!=d) break;
}
if (i==dirName.size())
{
bool directoryMatched = false;
if (!dirNameHasTrailingSlash)
{
// no trailing slash on dirName so we won't have matched
// the required slash on filename to make sure the
next character is slash.
char f = filename[i];
// check for slash
if (f=='\\' || f=='/')
{
// found slash, now need to skip over it.
++i;
directoryMatched = true;
}
}
else
{
directoryMatched = true;
}
if (directoryMatched)
{
files.push_back(filename.substr(i));
}
}
}
}
return files;
}
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org