diff --git a/applications/osgconv/CMakeLists.txt b/applications/osgconv/CMakeLists.txt index 117d5e8e6..cff54cb79 100644 --- a/applications/osgconv/CMakeLists.txt +++ b/applications/osgconv/CMakeLists.txt @@ -1,7 +1,15 @@ #this file is automatically generated -SET(TARGET_SRC OrientationConverter.cpp osgconv.cpp ) -SET(TARGET_H OrientationConverter.h ) +SET(TARGET_SRC + OrientationConverter.cpp + PluginQuery.cpp + osgconv.cpp +) +SET(TARGET_H + OrientationConverter.h + PluginQuery.h +) + #### end var setup ### SETUP_APPLICATION(osgconv) diff --git a/applications/osgconv/PluginQuery.cpp b/applications/osgconv/PluginQuery.cpp new file mode 100644 index 000000000..50115ca74 --- /dev/null +++ b/applications/osgconv/PluginQuery.cpp @@ -0,0 +1,41 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield + * + * This application is open source and may be redistributed and/or modified + * freely and without restriction, both in commericial and non commericial applications, + * as long as this copyright notice is maintained. + * + * This application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#include +#include + +#include "PluginQuery.h" + +using namespace osgDB; + +FileNameList osgDB::listAllAvailablePlugins() +{ + FileNameList pluginFiles; + + std::string pluginDirectoryName = std::string("osgPlugins-")+std::string(osgGetVersion()); + std::string fullPath = osgDB::findLibraryFile(pluginDirectoryName); + if (!fullPath.empty()) + { + osgDB::DirectoryContents contents = getDirectoryContents(fullPath); + for(DirectoryContents::iterator itr = contents.begin(); + itr != contents.end(); + ++itr) + { + std::string::size_type pos = itr->find("osgdb_"); + if (pos!=std::string::npos) + { + pluginFiles.push_back(fullPath + std::string("/")+*itr); + } + } + } + + return pluginFiles; +} diff --git a/applications/osgconv/PluginQuery.h b/applications/osgconv/PluginQuery.h new file mode 100644 index 000000000..b1c0b029d --- /dev/null +++ b/applications/osgconv/PluginQuery.h @@ -0,0 +1,28 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield + * + * This application is open source and may be redistributed and/or modified + * freely and without restriction, both in commericial and non commericial applications, + * as long as this copyright notice is maintained. + * + * This application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#ifndef PLUGINQUERY_H +#define PLUGINQUERY_H + +#include + +namespace osgDB +{ + +typedef std::list FileNameList; + + +FileNameList listAllAvailablePlugins(); + + +} + +#endif diff --git a/applications/osgconv/osgconv.cpp b/applications/osgconv/osgconv.cpp index 050c6663e..1fa45a29c 100644 --- a/applications/osgconv/osgconv.cpp +++ b/applications/osgconv/osgconv.cpp @@ -28,6 +28,7 @@ #include #include "OrientationConverter.h" +#include "PluginQuery.h" typedef std::vector FileNameList; @@ -506,6 +507,7 @@ int main( int argc, char **argv ) arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters"); arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available"); + arguments.getApplicationUsage()->addCommandLineOption("--fmts","List supported file formats"); // if user request help write it out to cout. @@ -522,6 +524,18 @@ int main( int argc, char **argv ) return 1; } + if (arguments.read("--fmts")) + { + osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins(); + for(osgDB::FileNameList::iterator itr = plugins.begin(); + itr != plugins.end(); + ++itr) + { + std::cout<<"Plugin "<<*itr<write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);