v1.0.0-rc.34

This commit is contained in:
2025-04-14 11:52:06 +02:00
parent 708b5fbc4b
commit b0607ab3ca
238 changed files with 4590 additions and 1329 deletions

View File

@@ -643,4 +643,41 @@ std::vector<std::string> HDF5Object::FindLeafs(const std::string &name) const {
H5Gclose(gid);
return ret;
}
}
std::string HDF5Object::GetLinkedFileName(const std::string& name) const {
H5L_info2_t link_info;
// Get information about the link
if (H5Lget_info(id, name.c_str(), &link_info, H5P_DEFAULT) < 0)
throw JFJochException(JFJochExceptionCategory::HDF5,
"Failed to retrieve information about the link");
if (link_info.type != H5L_TYPE_EXTERNAL)
throw JFJochException(JFJochExceptionCategory::HDF5,
"This is not an external link");
std::vector<char> link_target(link_info.u.val_size + 2, '\0');
if (H5Lget_val(id,
name.c_str(),
link_target.data(),
link_info.u.val_size + 1, H5P_DEFAULT) < 0)
throw JFJochException(JFJochExceptionCategory::HDF5,
"Failed to get link location");
const char *target_file_name = nullptr; // To store unpacked file name
const char *target_object_path = nullptr; // To store unpacked object path
// Unpack the external link's value
if (H5Lunpack_elink_val(link_target.data(),
link_info.u.val_size,
nullptr,
&target_file_name,
&target_object_path) < 0)
throw JFJochException(JFJochExceptionCategory::HDF5,
"Failed to get link location");
std::string s(target_file_name);
return s;
}