Commit 868558c7 authored by Burlen Loring's avatar Burlen Loring

VTK posthoc io create dir if it doesn't exist

parent c8a15ce5
......@@ -27,6 +27,10 @@
#include <fstream>
#include <cassert>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <vtkAlgorithm.h>
#include <vtkCompositeDataPipeline.h>
#include <vtkXMLDataSetWriter.h>
......@@ -102,6 +106,22 @@ VTKPosthocIO::~VTKPosthocIO()
//-----------------------------------------------------------------------------
int VTKPosthocIO::SetOutputDir(const std::string &outputDir)
{
int rank = 0;
MPI_Comm_rank(this->GetCommunicator(), &rank);
// rank 0 ensures that directory is present
if (rank == 0)
{
int ierr = mkdir(outputDir.c_str(), S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
if (ierr && (errno != EEXIST))
{
const char *estr = strerror(errno);
SENSEI_ERROR("Directory \"" << outputDir
<< "\" does not exist and we could not create it. " << estr)
return -1;
}
}
this->OutputDir = outputDir;
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment