Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added creation of directory path for ouput if one is required

  • Loading branch information...
commit e670518dc29c3f504603ca22d329e700c7cc1093 1 parent fb35cb3
Robert OSFIELD authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 examples/osgframerenderer/osgframerenderer.cpp
View
25 examples/osgframerenderer/osgframerenderer.cpp
@@ -1,4 +1,5 @@
#include <osgDB/ReadFile>
+#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
@@ -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();
Please sign in to comment.
Something went wrong with that request. Please try again.