Skip to content

Commit

Permalink
Added creation of directory path for ouput if one is required
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Dec 6, 2012
1 parent fb35cb3 commit e670518
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/osgframerenderer/osgframerenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
Expand Down Expand Up @@ -407,6 +408,30 @@ int main( int argc, char **argv )
viewer.getCamera()->setReadBuffer(buffer);
}

std::string outputPath = osgDB::getFilePath(fc->getOutputFileName());
if (!outputPath.empty())
{
osgDB::FileType type = osgDB::fileType(outputPath);
switch(type)
{
case(osgDB::FILE_NOT_FOUND):
if (!osgDB::makeDirectory(outputPath))
{
OSG_NOTICE<<"Error: could not create directory ["<<outputPath<<"]."<<std::endl;
return 1;
}
OSG_NOTICE<<"Created directory ["<<outputPath<<"]."<<std::endl;
break;
case(osgDB::REGULAR_FILE):
OSG_NOTICE<<"Error: filepath for output files is regular file, not a directory as required."<<std::endl;
return 1;
case(osgDB::DIRECTORY):
OSG_NOTICE<<"Valid path["<<outputPath<<"] provided for output files."<<std::endl;
break;
}
}


viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
viewer.realize();

Expand Down

0 comments on commit e670518

Please sign in to comment.