aboutsummaryrefslogtreecommitdiff
path: root/CarpetDev/CarpetIOF5/src/file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'CarpetDev/CarpetIOF5/src/file.cc')
-rw-r--r--CarpetDev/CarpetIOF5/src/file.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/CarpetDev/CarpetIOF5/src/file.cc b/CarpetDev/CarpetIOF5/src/file.cc
index 0582e2071..07366f072 100644
--- a/CarpetDev/CarpetIOF5/src/file.cc
+++ b/CarpetDev/CarpetIOF5/src/file.cc
@@ -1,4 +1,5 @@
#include <cassert>
+#include <string>
#include <hdf5.h>
@@ -14,26 +15,29 @@ namespace CarpetIOF5 {
file_t::
file_t (cGH const * const cctkGH,
- char const * const filename,
+ string const filename,
bool const do_truncate)
: m_cctkGH (cctkGH),
m_filename (filename)
{
assert (cctkGH);
- assert (filename);
- htri_t is_hdf5 = H5Fis_hdf5 (filename);
- assert (is_hdf5 >= 0);
+ char const * const filenameptr = filename.c_str();
+
+ htri_t is_hdf5;
+ H5E_BEGIN_TRY {
+ is_hdf5 = H5Fis_hdf5 (filenameptr);
+ } H5E_END_TRY;
bool const file_exists = is_hdf5 > 0;
if (do_truncate or ! file_exists)
{
m_hdf5_file
- = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ = H5Fcreate (filenameptr, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
}
else
{
- m_hdf5_file = H5Fopen (filename, H5F_ACC_RDWR, H5P_DEFAULT);
+ m_hdf5_file = H5Fopen (filenameptr, H5F_ACC_RDWR, H5P_DEFAULT);
}
assert (invariant());
@@ -73,7 +77,6 @@ namespace CarpetIOF5 {
const
{
return (m_cctkGH != 0
- and m_filename != 0
and m_hdf5_file >= 0);
}