diff --git a/include/openPMD/IO/AbstractIOHandlerImpl.hpp b/include/openPMD/IO/AbstractIOHandlerImpl.hpp index d204b8bc90..e43dcbd6a2 100644 --- a/include/openPMD/IO/AbstractIOHandlerImpl.hpp +++ b/include/openPMD/IO/AbstractIOHandlerImpl.hpp @@ -238,6 +238,7 @@ class AbstractIOHandlerImpl * * The operation should overwrite existing file positions, even when the Writable was already marked written. * The path parameters.path may contain multiple levels (e.g. first/second/third/). This path should be relative (i.e. it should not start with a slash "/"). + * The number of levels may be zero, i.e. parameters.path may be an empty string. * The Writables file position should correspond to the complete opened path (i.e. first/second/third/ should be assigned to the Writables file position). * The Writable should be marked written when the operation completes successfully. */ diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index 8b5b38edd3..a7697a7ce7 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -518,19 +518,23 @@ HDF5IOHandlerImpl::openPath( /* Sanitize path */ std::string path = parameters.path; - if( auxiliary::starts_with(path, '/') ) - path = auxiliary::replace_first(path, "/", ""); - if( !auxiliary::ends_with(path, '/') ) - path += '/'; + if( !path.empty() ) + { + if( auxiliary::starts_with(path, '/') ) + path = auxiliary::replace_first(path, "/", ""); + if( !auxiliary::ends_with(path, '/') ) + path += '/'; + path_id = H5Gopen(node_id, + path.c_str(), + H5P_DEFAULT); + VERIFY(path_id >= 0, "[HDF5] Internal error: Failed to open HDF5 group during path opening"); - path_id = H5Gopen(node_id, - path.c_str(), - H5P_DEFAULT); - VERIFY(path_id >= 0, "[HDF5] Internal error: Failed to open HDF5 group during path opening"); + herr_t status; + status = H5Gclose(path_id); + VERIFY(status == 0, "[HDF5] Internal error: Failed to close HDF5 group during path opening"); + } herr_t status; - status = H5Gclose(path_id); - VERIFY(status == 0, "[HDF5] Internal error: Failed to close HDF5 group during path opening"); status = H5Gclose(node_id); VERIFY(status == 0, "[HDF5] Internal error: Failed to close HDF5 group during path opening"); diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index be2bc42cd6..0078bdc845 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -3188,12 +3188,10 @@ stepBasedSingleIteration( std::string const & file ) TEST_CASE( "stepBasedSingleIteration", "[serial][adios2]" ) { - stepBasedSingleIteration("../samples/stepBasedSingleIteration.bp"); - stepBasedSingleIteration("../samples/stepBasedSingleIteration.json"); - // for( auto const & t : getFileExtensions() ) - // { - // stepBasedSingleIteration( "../samples/stepBasedSingleIteration." + t ); - // } + for( auto const & t : getFileExtensions() ) + { + stepBasedSingleIteration( "../samples/stepBasedSingleIteration." + t ); + } } #if openPMD_HAVE_ADIOS2