From c19a23656110d2d12428d325c6841b2aaa84b145 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 11 Dec 2002 14:24:44 +0000 Subject: [PATCH] Added code to the path to the executable, adding it into the libary and data file paths. --- src/Demos/osggeodemo/osggeodemo.cpp | 32 ++++++++++------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/Demos/osggeodemo/osggeodemo.cpp b/src/Demos/osggeodemo/osggeodemo.cpp index dbcc665da..f1e9afbb1 100644 --- a/src/Demos/osggeodemo/osggeodemo.cpp +++ b/src/Demos/osggeodemo/osggeodemo.cpp @@ -17,6 +17,8 @@ #include #include +#include +#include #include @@ -154,27 +156,15 @@ int main( int argc, char **argv ) osgGLUT::Viewer viewer; viewer.setWindowTitle(argv[0]); - // geoff's path code.. needs replacing as it isn't cross platform. -// { -// char *gdpath=getenv("PATH"); -// int lenpath=(gdpath ? strlen(gdpath):1) + strlen(argv[0]); -// char *nupath=new char[lenpath+20]; -// -// strcpy(nupath,"PATH="); -// strcat(nupath,argv[0]); -// // strip the executable name (xxx.exe) -// char *epath=strrchr(nupath, '\\'); -// if (epath) *epath='\0'; // remove executable -// else { -// epath=strrchr(nupath, '/'); -// if (epath) *epath='\0'; // remove executable, UNIX style path -// } -// strcat(nupath,";"); -// strcat(nupath,gdpath); -// _putenv(nupath); -// delete [] nupath; -// } -// std::cout << "Path " << getenv("PATH") << std::endl; + + // get the path of the executable and use it to set internal data and library paths. + std::string executablePath = osgDB::getFilePath(argv[0]); + if (!executablePath.empty()) + { + std::osg::notify(osg::NOTICE) << "Adding executable path '"<