In HDF5 path names, ..
does not have the meaning it does in a shell. ..
is a legitimate link name. In the example below, two groups are created. The first is linked as ..
under the root group, the second is linked as ...
in the first group.
In HDF5, ..
cannot have the meaning of “one level above in the hierarchy”, because we are dealing with multi-graphs. A node can have multiple (direct) parents, and the concept of level is meaningful only for tree-like structures.
Only the path separator /
and the combination ./
and /./
are special. A single space or multiple spaces are legitimate link names.
G.
Example
#include "hdf5.h"
#include <stdlib.h>
int main()
{
__label__ fail_group, fail_prop, fail_lcpl, fail_file;
int ret_val = EXIT_SUCCESS;
hid_t file, lcpl, group;
char fname[] = "g2.h5";
char path[] = "./../...";
if ((file = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) ==
H5I_INVALID_HID) {
ret_val = EXIT_FAILURE;
goto fail_file;
}
if ((lcpl = H5Pcreate(H5P_LINK_CREATE)) == H5I_INVALID_HID) {
ret_val = EXIT_FAILURE;
goto fail_lcpl;
}
// ensure that intermediate groups are created automatically
if (H5Pset_create_intermediate_group(lcpl, 1) < 0) {
ret_val = EXIT_FAILURE;
goto fail_prop;
}
// create two groups
if ((group = H5Gcreate(file, path, lcpl, H5P_DEFAULT, H5P_DEFAULT)) ==
H5I_INVALID_HID) {
ret_val = EXIT_FAILURE;
goto fail_group;
}
H5Gclose(group);
fail_group:
fail_prop:
H5Pclose(lcpl);
fail_lcpl:
H5Fclose(file);
fail_file:
return ret_val;
}
$ h5dump g2.h5
HDF5 "g2.h5" {
GROUP "/" {
GROUP ".." {
GROUP "..." {
}
}
}