[cig-commits] r13552 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:14:07 PST 2008
Author: luis
Date: 2008-12-09 18:14:06 -0800 (Tue, 09 Dec 2008)
New Revision: 13552
Modified:
cs/cigma/trunk/src/core_writers.cpp
cs/cigma/trunk/src/io_file_reader.h
Log:
Updates to cigma::WriteArray
Modified: cs/cigma/trunk/src/core_writers.cpp
===================================================================
--- cs/cigma/trunk/src/core_writers.cpp 2008-12-10 02:14:04 UTC (rev 13551)
+++ cs/cigma/trunk/src/core_writers.cpp 2008-12-10 02:14:06 UTC (rev 13552)
@@ -7,6 +7,7 @@
#include <boost/shared_ptr.hpp>
using boost::shared_ptr;
+#include <string>
#include <sstream>
using namespace std;
@@ -17,11 +18,23 @@
TRI_LOG(path);
std::string filename = path.filename();
+ std::string location = path.location();
+
+ // XXX: implement read/write mode so we don't truncate an existing file
shared_ptr<FileWriter> writer = FileWriter::New(filename, "w");
+
const FileWriter::WriterType wt = writer->getWriterType();
if (wt == FileWriter::HDF5_FILE_WRITER)
{
- throw cigma::Exception("WriteArray", "Need HDF5 writer");
+ const double *data = x._data;
+ int status = writer->writeDataset(location.c_str(), data, x.n_points(), x.n_dim());
+ if (status < 0)
+ {
+ std::ostringstream stream;
+ stream << "Could not write dataset '" << location
+ << "' to the HDF5 file '" << filename << "'" << std::ends;
+ throw cigma::Exception("WriteArray", stream.str());
+ }
}
else if (wt == FileWriter::VTK_FILE_WRITER)
{
@@ -33,7 +46,9 @@
int status = writer->writeDataset("", data, x.n_points(), x.n_dim());
if (status < 0)
{
- throw cigma::Exception("WriteArray", "Could not write dataset to text file");
+ std::ostringstream stream;
+ stream << "Could not write dataset to the text file '" << filename << "'" << std::ends;
+ throw cigma::Exception("WriteArray", stream.str());
}
}
else
Modified: cs/cigma/trunk/src/io_file_reader.h
===================================================================
--- cs/cigma/trunk/src/io_file_reader.h 2008-12-10 02:14:04 UTC (rev 13551)
+++ cs/cigma/trunk/src/io_file_reader.h 2008-12-10 02:14:06 UTC (rev 13552)
@@ -5,6 +5,7 @@
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include "Filesystem.h"
+#include "Exception.h"
namespace cigma
{
More information about the CIG-COMMITS
mailing list