How do I get the prefix of a visited external link?

Hello!

Using the C library on a POSIX platform, how do I get the prefix of a visited external link?

I call H5Lvisit, and then my callback function with arguments (hid_t group, const char *name, const H5L_info_t *info, void *op_data) is called for each link, and I can select only external links by testing for info->type == H5L_TYPE_EXTERNAL. But how do I get the prefix, if any, for the external link?

I’ve read the documentation for H5Lget_val(), and it says that for external links the lapl_id argument needs to be a non-default link access property list because an external link may require a prefix. It references H5Pset_elink_prefix(), but I don’t want to set it, I want to get it. I see there’s an H5Pget_elink_prefix() function as well, which looked promising, but its arguments are (hid_t plist_id, char *prefix, size_t size), and I don’t know what I’m supposed to use for the plist_id argument; should I use the group argument of my callback function? Where is the prefix stored?

What I’m ultimately trying to do is rename the filename that the external link points to, so I’m deleting the external link and creating a new one with the new filename, but I want to ensure that I don’t lose the prefix if one is set.

Thanks!

Thanks for the question! the elink prefix is set on a link access property list, so it is not stored in the file. Every time an external link is traversed, the library looks at the elink prefix on the LAPL passed in by the application for that operation, so the same external link can be used with different prefixes for different operations (this might be useful if the parent and/or external files are moved). The equivalent of a persistent elink prefix would be to simply store the full path name in the external link target value.

Ah, I see, the prefix is not stored in the file! That’s the key thing I didn’t understand. So, for what I’m ultimately trying to do where I’m renaming the filename that the external link points to, I don’t have to do anything with the prefix. Thanks!

1 Like