Hi Robert, Thanks, based on your feedback I think I'll go ahead and refactor some of the stuff into the base Archive to use getFileNames() so we don't have the code duplication. In the ZipArchive I simply rearrange the path string to be in linux format which simplifies the code to parse the directory structure. That also requires converting and storing the filenames in linux format so getFileNames() returns a linux like path. I guess I would only parse and store the file names for lookup the first time getDirectoryContents() is used. Then it can still look them up efficiently it just may take a little longer the first time.
While I'd like to dive in and go ahead and make those changes now, I've got a major deliverable Wednesday so I might not have them for you until the later end of the week. Brad -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Robert Osfield Sent: Friday, April 29, 2011 12:54 PM To: OpenSceneGraph Submissions Subject: Re: [osg-submissions] Registry modifications 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-openscenegr aph.org _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
