#include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(_WIN32) && !defined(__CYGWIN__) #include #else #include #endif using namespace osg; class ReaderWriterTGZ : public osgDB::ReaderWriter { public: virtual const char* className() const { return "TGZ Database Reader/Writer"; } ReaderWriterTGZ() { supportsExtension("tgz","Tar gzip'd archive format"); } virtual ReadResult readObject(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const { return readNode(fileName, options); } virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(file); if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; OSG_NOTICE<<"file="< grp = new osg::Group; OSG_NOTICE<<"Done"< local_options = options ? static_cast(options->clone(osg::CopyOp::SHALLOW_COPY)) : new osgDB::ReaderWriter::Options; local_options->getDatabasePathList().push_front(dirname); OSG_NOTICE<<"local_options->getDatabasePathList().="<getDatabasePathList().front()< node = osgDB::readRefNodeFile(*itr, local_options.get()); if (node) grp->addChild( node ); } } // restorre original state of the automatic generation of images to geode's. osgDB::Registry::instance()->setCreateNodeFromImage(prevCreateNodeFromImage); #if defined(_WIN32) && !defined(__CYGWIN__) sprintf( command, "erase /F /Q /S \"%s\"", dirname ); #else sprintf( command, "rm -rf %s", dirname ); #endif OSG_NOTICE<<"Running command '"<getNumChildren() == 0 ) { return ReadResult::FILE_NOT_HANDLED; } return grp; } }; // now register with sgRegistry to instantiate the above // reader/writer. REGISTER_OSGPLUGIN(tgz, ReaderWriterTGZ)