Removed temporary makeDir files and call in ReaderWriterNet.cpp

This commit is contained in:
Don BURNS 2004-09-20 17:42:40 +00:00
parent 0750a19aa6
commit 95b9ec54e9
3 changed files with 2 additions and 86 deletions

View File

@ -5,7 +5,6 @@ CXXFILES =\
ReaderWriterNET.cpp\
sockinet.cpp\
sockstream.cpp\
makeDir.cpp\
LIBS += $(OSG_LIBS) $(OTHER_LIBS)

View File

@ -6,6 +6,7 @@
#include <osgDB/Input>
#include <osgDB/Registry>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
@ -13,7 +14,6 @@
#include <osg/MatrixTransform>
#include <osg/Group>
#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 <<

View File

@ -1,83 +0,0 @@
//
// This should move to osgDB::FileUtils
//
#include <iostream>
#include <stdio.h>
#ifndef WIN32
#include <libgen.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include <errno.h>
#include <string>
#include <stack>
#include <osgDB/FileUtils>
#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<std::string> 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
}
}