summaryrefslogtreecommitdiffstats
path: root/tools/h5copy/h5copy.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2010-04-22 18:17:35 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2010-04-22 18:17:35 (GMT)
commit249acc03550e9cb2ed3cfaa56737215910a7a194 (patch)
treeff576ef83e636639b4a707bb174466afdc39af5f /tools/h5copy/h5copy.c
parent20a020a1c7bccce730be91118b3366b7cabe95fc (diff)
downloadhdf5-249acc03550e9cb2ed3cfaa56737215910a7a194.zip
hdf5-249acc03550e9cb2ed3cfaa56737215910a7a194.tar.gz
hdf5-249acc03550e9cb2ed3cfaa56737215910a7a194.tar.bz2
[svn-r18614] Purpose:
Fix for bug 1817 : h5copy fail to copy dangling link by specifying link path directly Tested: jam, amani, linew
Diffstat (limited to 'tools/h5copy/h5copy.c')
-rw-r--r--tools/h5copy/h5copy.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index 992195d..0ea8e16 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -213,6 +213,8 @@ main (int argc, const char *argv[])
hid_t lcpl_id = (-1); /* Link creation property list */
char str_flag[20];
int opt;
+ int li_ret;
+ h5tool_link_info_t linkinfo;
/* initialize h5tools lib */
h5tools_init();
@@ -406,7 +408,22 @@ main (int argc, const char *argv[])
/*-------------------------------------------------------------------------
* do the copy
*-------------------------------------------------------------------------*/
-
+ /* init linkinfo struct */
+ memset(&linkinfo, 0, sizeof(h5tool_link_info_t));
+
+ if(verbose)
+ linkinfo.opt.msg_mode = 1;
+
+ li_ret = H5tools_get_link_info(fid_src, oname_src, &linkinfo);
+ if (li_ret == 0) /* dangling link */
+ {
+ if(H5Lcopy(fid_src, oname_src,
+ fid_dst, oname_dst,
+ H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto error;
+ }
+ else /* valid link */
+ {
if (H5Ocopy(fid_src, /* Source file or group identifier */
oname_src, /* Name of the source object to be copied */
fid_dst, /* Destination file or group identifier */
@@ -414,6 +431,11 @@ main (int argc, const char *argv[])
ocpl_id, /* Object copy property list */
lcpl_id)<0) /* Link creation property list */
goto error;
+ }
+
+ /* free link info path */
+ if (linkinfo.trg_path)
+ free(linkinfo.trg_path);
/* close propertis */
if(H5Pclose(ocpl_id)<0)
@@ -442,6 +464,11 @@ main (int argc, const char *argv[])
error:
printf("Error in copy...Exiting\n");
+
+ /* free link info path */
+ if (linkinfo.trg_path)
+ free(linkinfo.trg_path);
+
H5E_BEGIN_TRY {
H5Pclose(ocpl_id);
H5Pclose(lcpl_id);