diff --git a/src/osgPlugins/net/GNUmakefile b/src/osgPlugins/net/GNUmakefile index 994004629..7ae7d60f8 100644 --- a/src/osgPlugins/net/GNUmakefile +++ b/src/osgPlugins/net/GNUmakefile @@ -5,7 +5,6 @@ CXXFILES =\ ReaderWriterNET.cpp\ sockinet.cpp\ sockstream.cpp\ - makeDir.cpp\ LIBS += $(OSG_LIBS) $(OTHER_LIBS) diff --git a/src/osgPlugins/net/ReaderWriterNET.cpp b/src/osgPlugins/net/ReaderWriterNET.cpp index 2bc616e23..3e3f0fe8f 100644 --- a/src/osgPlugins/net/ReaderWriterNET.cpp +++ b/src/osgPlugins/net/ReaderWriterNET.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -13,7 +14,6 @@ #include #include #include "sockinet.h" -#include "makeDir.h" /* * Semantics: @@ -286,7 +286,7 @@ class NetReader : public osgDB::ReaderWriter if( !localCacheDir.empty() && cacheMode & Write ) { std::string cacheFile = localCacheDir + '/' + fileName; - if( TemporaryFileUtils::makeDirectory( cacheFile ) ) + if( osgDB::makeDirectoryForFile( cacheFile ) ) { osgDB::writeNodeFile( *(readResult.getNode()), cacheFile ); osg::notify(osg::DEBUG_INFO) << "osgPlugin .net: " << fileName << diff --git a/src/osgPlugins/net/makeDir.cpp b/src/osgPlugins/net/makeDir.cpp deleted file mode 100644 index eba60c9b3..000000000 --- a/src/osgPlugins/net/makeDir.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// -// This should move to osgDB::FileUtils -// - -#include -#include -#ifndef WIN32 -#include -#include -#include -#include -#endif - -#include -#include -#include -#include -#include "makeDir.h" - -namespace TemporaryFileUtils { - -bool makeDirectory( const std::string &path ) -{ -#ifdef WIN32 - return false; -#else - char *cpath = new char[path.length()+1]; - strcpy( cpath, path.c_str()); - char *p = dirname(cpath); - struct stat stbuf; - - if( stat( p, &stbuf ) == 0 ) - { - if( S_ISDIR(stbuf.st_mode)) - return true; - else - { - std::cerr << "TemporaryFileUtils::makeDirectory() - "<< p - << " already exists and is not a directory!" << std::endl; - return false; - } - } - - std::stack paths; - while( true ) - { - if( p[0] == '.' ) - break; - - if( stat( p, &stbuf ) < 0 ) - { - switch( errno ) - { - case ENOENT: - case ENOTDIR: - paths.push( std::string(p) ); - break; - - default: - perror( p ); - return false; - } - } - p = dirname(p); - } ; - - while( !paths.empty() ) - { - std::string dir = paths.top(); - - if( mkdir( dir.c_str(), 0755 )< 0 ) - { - perror( dir.c_str() ); - return false; - } - - paths.pop(); - } - return true; -#endif -} - -}