You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
template <typename Derivate>
inlinebool NodeTraits<Derivate>::_exist(const std::string& node_name, bool raise_errors) const {
SilenceHDF5 silencer{};
constauto val =
H5Lexists(static_cast<const Derivate*>(this)->getId(), node_name.c_str(), H5P_DEFAULT);
if (val < 0) {
if (raise_errors) {
HDF5ErrMapper::ToException<GroupException>("Invalid link for exist()");
} else {
returnfalse;
}
}
// The root path always exists, but H5Lexists return 0 or 1// depending of the version of HDF5, so always return true for it// We had to call H5Lexists anyway to check that there are no errorsreturn (node_name == "/") ? true : (val > 0);
}
template <typename Derivate>
inlinebool NodeTraits<Derivate>::exist(const std::string& group_path) const {
// When there are slashes, first check everything is fine// so that subsequent errors are only due to missing intermediate groupsif (group_path.find('/') != std::string::npos) {
_exist("/"); // Shall not throw under normal circumstances// Unless "/" (already checked), verify path exists (not throwing errors)return (group_path == "/") ? true : _exist(group_path, false);
}
return_exist(group_path);
}
The code in question is:
which goes against the recommendations of HDF5, as to how we should check if a nested link exists. I'd like to also be able to check the existence of attributes. Here is the documentation of
H5Lexists
:https://docs.hdfgroup.org/hdf5/v1_12/group___h5_l.html#ga171be6e41dc1a464edc402df0ebdf801
which includes a pseudo-algorithm for correctly checking existence of nested links.
The text was updated successfully, but these errors were encountered: