diff options
Diffstat (limited to 'tools/h5dump/h5dumpgentest.c')
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 76a2b43..63cb1e8 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -88,6 +88,9 @@ #define FILE58 "tordergr.h5" #define FILE59 "torderattr.h5" #define FILE60 "tfpformat.h5" +#define FILE61 "textlinksrc.h5" +#define FILE62 "textlinktar.h5" + @@ -6174,6 +6177,66 @@ gent_fpformat(void) H5Fclose(fid); } +/*------------------------------------------------------------------------- + * Function: gent_extlinks + * + * Purpose: Generate 2 files to be used in the external links test + * External links point from one HDF5 file to an object (Group, Dataset, or + * committed Datatype) in another file. + * + *------------------------------------------------------------------------- + */ +static void +gent_extlinks(void) +{ + hid_t source_fid, target_fid, sid, did, gid, tid; + hsize_t dims[1] = {6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; + + /* create two files, a source and a target */ + source_fid = H5Fcreate(FILE61, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + target_fid = H5Fcreate(FILE62, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + +/*------------------------------------------------------------------------- + * create a Group, a Dataset, and a committed Datatype in the target + *------------------------------------------------------------------------- + */ + + gid = H5Gcreate2(target_fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(gid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + H5Dclose(did); + H5Sclose(sid); + H5Gclose(gid); + + + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(target_fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + H5Dclose(did); + H5Sclose(sid); + + tid = H5Tcopy(H5T_NATIVE_INT); + H5Tcommit2(target_fid, "type", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Tclose(tid); + +/*------------------------------------------------------------------------- + * create external links in the source file pointing to the target objects + *------------------------------------------------------------------------- + */ + + H5Lcreate_external(FILE62, "group", source_fid, "ext_link1", H5P_DEFAULT, H5P_DEFAULT); + H5Lcreate_external(FILE62, "dset", source_fid, "ext_link2", H5P_DEFAULT, H5P_DEFAULT); + H5Lcreate_external(FILE62, "type", source_fid, "ext_link3", H5P_DEFAULT, H5P_DEFAULT); + + /* close */ + H5Fclose(source_fid); + H5Fclose(target_fid); +} + + /*------------------------------------------------------------------------- * Function: main @@ -6243,6 +6306,7 @@ int main(void) gent_group_creation_order(); gent_attr_creation_order(); gent_fpformat(); + gent_extlinks(); return 0; |