summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/h5repack_copy.c56
-rw-r--r--tools/h5repack/h5repack_list.c3
-rw-r--r--tools/h5repack/h5repack_refs.c6
-rw-r--r--tools/h5repack/testh5repack_dset.c2
-rw-r--r--tools/h5repack/testh5repack_main.c1
-rw-r--r--tools/h5repack/testh5repack_make.c19
6 files changed, 47 insertions, 40 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index dee6c3f..e59b6d0 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -264,17 +264,17 @@ int do_copy_objects(hid_t fidin,
trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
- hid_t grp_in; /* group ID */
- hid_t grp_out; /* group ID */
- hid_t dset_in; /* read dataset ID */
- hid_t dset_out; /* write dataset ID */
- hid_t type_in; /* named type ID */
- hid_t type_out; /* named type ID */
- hid_t dcpl_id; /* dataset creation property list ID */
- hid_t dcpl_out; /* dataset creation property list ID */
- hid_t space_id; /* space ID */
- hid_t ftype_id; /* file data type ID */
- hid_t mtype_id; /* memory data type ID */
+ hid_t grp_in=-1; /* group ID */
+ hid_t grp_out=-1; /* group ID */
+ hid_t dset_in=-1; /* read dataset ID */
+ hid_t dset_out=-1; /* write dataset ID */
+ hid_t type_in=-1; /* named type ID */
+ hid_t type_out=-1; /* named type ID */
+ hid_t dcpl_id=-1; /* dataset creation property list ID */
+ hid_t dcpl_out=-1; /* dataset creation property list ID */
+ hid_t space_id=-1; /* space ID */
+ hid_t ftype_id=-1; /* file data type ID */
+ hid_t mtype_id=-1; /* memory data type ID */
size_t msize; /* memory size of memory type */
void *buf=NULL; /* data buffer */
hsize_t nelmts; /* number of elements in dataset */
@@ -561,30 +561,18 @@ int do_copy_objects(hid_t fidin,
/*-------------------------------------------------------------------------
* H5G_LINK
+ * H5G_UDLINK
+ *
+ * Only handles external links; H5Lcopy will fail for other UD link types
+ * since we don't have creation or copy callbacks for them.
*-------------------------------------------------------------------------
*/
case H5G_LINK:
+ case H5G_UDLINK:
{
- H5G_stat_t statbuf;
- char *targbuf=NULL;
-
- if (H5Gget_objinfo(fidin,travt->objs[i].name,FALSE,&statbuf)<0)
- goto error;
-
- targbuf = malloc(statbuf.linklen);
-
- if (H5Gget_linkval(fidin,travt->objs[i].name,statbuf.linklen,targbuf)<0)
- goto error;
-
- if (H5Glink(fidout,
- H5G_LINK_SOFT,
- targbuf, /* current name of object */
- travt->objs[i].name /* new name of object */
- )<0)
- goto error;
-
- free(targbuf);
+ if(H5Lcopy(fidin, travt->objs[i].name,fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto error;
if (options->verbose)
printf(FORMAT_OBJ,"link",travt->objs[i].name );
@@ -592,6 +580,14 @@ int do_copy_objects(hid_t fidin,
}
break;
+/*-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
+ */
+ {
+
+ }
+ break;
+
default:
goto error;
}
diff --git a/tools/h5repack/h5repack_list.c b/tools/h5repack/h5repack_list.c
index 05156d4..5622811 100644
--- a/tools/h5repack/h5repack_list.c
+++ b/tools/h5repack/h5repack_list.c
@@ -198,6 +198,9 @@ void print_objlist(const char *filename,
case H5G_LINK:
printf(" %-10s %s\n", "link", info[i].name );
break;
+ case H5G_UDLINK:
+ printf(" %-10s %s\n", "User defined link", info[i].name );
+ break;
default:
printf(" %-10s %s\n", "User defined object", info[i].name );
break;
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index 6e3156b..4884e04 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -93,7 +93,7 @@ int do_copy_refobjs(hid_t fidin,
for ( j=0; j<travt->objs[i].nlinks; j++)
{
H5Glink(fidout,
- H5G_LINK_HARD,
+ H5L_LINK_HARD,
travt->objs[i].name,
travt->objs[i].links[j].new_name);
}
@@ -339,7 +339,7 @@ int do_copy_refobjs(hid_t fidin,
{
for ( j=0; j<travt->objs[i].nlinks; j++){
H5Glink(fidout,
- H5G_LINK_HARD,
+ H5L_LINK_HARD,
travt->objs[i].name,
travt->objs[i].links[j].new_name);
}
@@ -384,10 +384,12 @@ int do_copy_refobjs(hid_t fidin,
/*-------------------------------------------------------------------------
* H5G_LINK
+ * H5G_UDLINK
*-------------------------------------------------------------------------
*/
case H5G_LINK:
+ case H5G_UDLINK:
/*nothing to do */
break;
diff --git a/tools/h5repack/testh5repack_dset.c b/tools/h5repack/testh5repack_dset.c
index c345028..ca0f0ca 100644
--- a/tools/h5repack/testh5repack_dset.c
+++ b/tools/h5repack/testh5repack_dset.c
@@ -128,7 +128,7 @@ void write_dset_in(hid_t loc_id,
/* create hard link */
- status = H5Glink(loc_id, H5G_LINK_HARD, "string", "string_link");
+ status = H5Glink(loc_id, H5L_LINK_HARD, "string", "string_link");
/*-------------------------------------------------------------------------
* H5T_BITFIELD
diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c
index 58a7c2a..5299cd4 100644
--- a/tools/h5repack/testh5repack_main.c
+++ b/tools/h5repack/testh5repack_main.c
@@ -1170,7 +1170,6 @@ if (szip_can_encode) {
SKIPPED();
#endif
-
/*-------------------------------------------------------------------------
* end
*-------------------------------------------------------------------------
diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c
index 43b68b1..a74d466 100644
--- a/tools/h5repack/testh5repack_make.c
+++ b/tools/h5repack/testh5repack_make.c
@@ -259,7 +259,14 @@ int make_all_objects(hid_t loc_id)
*-------------------------------------------------------------------------
*/
- H5Glink(loc_id, H5G_LINK_SOFT, "dset", "link");
+ H5Glink(loc_id, H5L_LINK_SOFT, "dset", "link");
+
+/*-------------------------------------------------------------------------
+ * H5G_UDLINK
+ *-------------------------------------------------------------------------
+ */
+ /* Create an external link. Other UD links are not supported by h5repack */
+ H5Lcreate_external("file", "path", loc_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
* write a series of datasetes
@@ -350,11 +357,11 @@ int make_hlinks(hid_t loc_id)
if (write_dset(loc_id,2,dims,"dset",H5T_NATIVE_INT,buf)<0)
return -1;
- if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link1 to dset")<0)
+ if (H5Glink(loc_id, H5L_LINK_HARD, "dset", "link1 to dset")<0)
return -1;
- if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link2 to dset")<0)
+ if (H5Glink(loc_id, H5L_LINK_HARD, "dset", "link2 to dset")<0)
return -1;
- if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link3 to dset")<0)
+ if (H5Glink(loc_id, H5L_LINK_HARD, "dset", "link3 to dset")<0)
return -1;
@@ -370,9 +377,9 @@ int make_hlinks(hid_t loc_id)
if ((group3_id = H5Gcreate(group2_id,"g3",0))<0)
return -1;
- if (H5Glink2(loc_id, "g1", H5G_LINK_HARD, group2_id, "link1 to g1")<0)
+ if (H5Glink2(loc_id, "g1", H5L_LINK_HARD, group2_id, "link1 to g1")<0)
return -1;
- if (H5Glink2(group1_id, "g2", H5G_LINK_HARD, group3_id, "link1 to g2")<0)
+ if (H5Glink2(group1_id, "g2", H5L_LINK_HARD, group3_id, "link1 to g2")<0)
return -1;
H5Gclose(group1_id);