Added ability to toggle on/off use of C system() function call, using OSG_SYSTEM_SUPPORTED Cmake option

This commit is contained in:
Robert Osfield
2018-01-12 19:52:31 +00:00
parent 6a3d9b2aa2
commit ae57f3cd46
10 changed files with 40 additions and 10 deletions

View File

@@ -35,5 +35,6 @@
#cmakedefine OSG_PROVIDE_READFILE
#cmakedefine OSG_USE_DEPRECATED_API
#cmakedefine OSG_ENVVAR_SUPPORTED
#cmakedefine OSG_SYSTEM_SUPPORTED
#endif

View File

@@ -19,6 +19,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include <osg/Config>
/*
** list of valid conversion specifiers for the 'strftime' function
@@ -78,6 +79,8 @@
static int os_execute (lua_State *L) {
#if defined(OSG_SYSTEM_SUPPORTED)
const char *cmd = luaL_optstring(L, 1, NULL);
int stat = system(cmd);
if (cmd != NULL)
@@ -86,6 +89,9 @@ static int os_execute (lua_State *L) {
lua_pushboolean(L, stat); /* true if there is a shell */
return 1;
}
#else
return 0;
#endif
}

View File

@@ -8,6 +8,7 @@
#include <osg/Geode>
#include <osg/Group>
#include <osg/Notify>
#include <osg/os_utils>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
@@ -77,7 +78,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
mkdir( dirname, 0700 );
#endif
if ( system( command ) ) {
if (osg::system( command ) ) {
return ReadResult::FILE_NOT_HANDLED;
}
@@ -107,7 +108,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
sprintf( command, "rm -rf %s", dirname );
#endif
if ( system( command ) ) {
if (osg::system( command ) ) {
return ReadResult::FILE_NOT_HANDLED;
}

View File

@@ -8,6 +8,7 @@
#include <osg/Geode>
#include <osg/Group>
#include <osg/Notify>
#include <osg/os_utils>
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
@@ -94,7 +95,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
OSG_NOTICE<<"Running command '"<<command<<"'"<<std::endl;
int result = system( command );
int result = osg::system( command );
if (result!=0) return ReadResult::ERROR_IN_READING_FILE;
@@ -137,7 +138,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
#endif
OSG_NOTICE<<"Running command '"<<command<<"'"<<std::endl;
result = system( command );
result = osg::system( command );
if (result!=0) return ReadResult::ERROR_IN_READING_FILE;
if( grp->getNumChildren() == 0 )

View File

@@ -14,6 +14,7 @@
#include <osgPresentation/SlideEventHandler>
#include <osgViewer/Viewer>
#include <osg/os_utils>
#include <osg/Notify>
#include <osgDB/FileUtils>
@@ -119,7 +120,7 @@ void KeyEventHandler::doOperation()
bool commandRunsInBackground = (_command.find("&")!=std::string::npos);
int result = system(_command.c_str());
int result = osg::system(_command.c_str());
OSG_INFO<<"system("<<_command<<") result "<<result<<std::endl;

View File

@@ -17,6 +17,7 @@
#include <osg/Notify>
#include <osgDB/FileUtils>
#include <osg/io_utils>
#include <osg/os_utils>
#include <stdlib.h>
@@ -230,7 +231,7 @@ void PickEventHandler::doOperation()
bool commandRunsInBackground = (_command.find("&")!=std::string::npos);
int result = system(_command.c_str());
int result = osg::system(_command.c_str());
OSG_INFO<<"system("<<_command<<") result "<<result<<std::endl;

View File

@@ -21,6 +21,7 @@
#include <osg/AlphaFunc>
#include <osg/Timer>
#include <osg/io_utils>
#include <osg/os_utils>
#include <osgUtil/TransformCallback>
#include <osgUtil/GLObjectsVisitor>
@@ -420,7 +421,7 @@ struct LayerAttributesOperator : public ObjectOperator
OSG_NOTICE<<"Run "<<itr->c_str()<<std::endl;
osg::Timer_t startTick = osg::Timer::instance()->tick();
int result = system(itr->c_str());
int result = osg::system(itr->c_str());
OSG_INFO<<"system("<<*itr<<") result "<<result<<std::endl;
@@ -1257,7 +1258,7 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
std::stringstream command;
command<<editor<<" "<<filename<<" &"<<std::endl;
int result = system(command.str().c_str());
int result = osg::system(command.str().c_str());
OSG_INFO<<"system("<<command.str()<<") result "<<result<<std::endl;

View File

@@ -31,6 +31,7 @@
#include <osg/ComputeBoundsVisitor>
#include <osg/Notify>
#include <osg/io_utils>
#include <osg/os_utils>
#include <osg/ValueObject>
#include <osgUtil/TransformCallback>
@@ -1749,7 +1750,7 @@ void SlideShowConstructor::addGraph(const std::string& contents, const PositionD
std::stringstream command;
command<<"dot -Tsvg "<<dotFileName<<" -o "<<tmpSvgFileName;
int result = system(command.str().c_str());
int result = osg::system(command.str().c_str());
if (result==0)
{
osg::ref_ptr<osgDB::Options> previousOptions = _options;