Hi,
Lets suppose that I have two files: file1.h5
and file2.h5
.
Then In file1.h5
I create empty group myGroup
.
Then I create external link to that group in fil2.h5
.
After that I want to get link name of that external link
#include <iostream>
#include "hdf5.h"
#define FILE1_NAME "file1.h5"
#define FILE2_NAME "file2.h5"
#define GROUP_NAME "myGroup"
#define LINK_NAME "myLink"
int main(void) {
hid_t file1, file2, group, link;
file1 = H5Fcreate(FILE1_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
file2 = H5Fcreate(FILE2_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
group = H5Gcreate2(file1, GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Lcreate_external(
FILE1_NAME,
GROUP_NAME,
file2,
LINK_NAME, H5P_DEFAULT, H5P_DEFAULT);
// open created external link to a group as a group, is it correct?
link = H5Gopen2(file2, LINK_NAME, H5P_DEFAULT);
char link_name_out[20];
H5Iget_name(link, link_name_out, 20);
// returned nameof a link is `myGroup` and not `myLink` as I expected
for (size_t i = 0; i < 20; i++)
std::cout << link_name_out[i];
std::cout << std::endl;
return 0; // successfully terminated
}
The output of an example is:
I expect that returned name of a link would be the same as given when creating this link LINK_NAME
but I get it equal to GROUP_NAME
even if I opened this group (link) with the name of LINK_NAME
In the same time if I create soft link
then the returned name is LINK_NAME
(as expected) wich means there is no such problem whith soft link
.
Moreover HDFViewer shows the name I expect: