summaryrefslogtreecommitdiffstats
path: root/tools/h5copy/h5copy.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2010-10-18 23:06:53 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2010-10-18 23:06:53 (GMT)
commite926608485fbfe593c00798d39b7a45b3bc15bdc (patch)
tree13112b613095fb92601da469ead67798a625f9b3 /tools/h5copy/h5copy.c
parent111f71366a3fb7ad7727dc3fda1a4f31dc788747 (diff)
downloadhdf5-e926608485fbfe593c00798d39b7a45b3bc15bdc.zip
hdf5-e926608485fbfe593c00798d39b7a45b3bc15bdc.tar.gz
hdf5-e926608485fbfe593c00798d39b7a45b3bc15bdc.tar.bz2
[svn-r19633] Purpose:
Fix for bug# 2040 - h5copy should fail gracefully for expected failure copying to non-exist nested group without -p option. Description: Fixed h5copy to fail gracefully when copying object to non-exist group without -p option. This is expected to be failed. Tested: jam, amani, heiwa
Diffstat (limited to 'tools/h5copy/h5copy.c')
-rw-r--r--tools/h5copy/h5copy.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index eb16754..e974063 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -215,12 +215,17 @@ main (int argc, const char *argv[])
int opt;
int li_ret;
h5tool_link_info_t linkinfo;
+ int i, len;
+ char *str_prt=NULL;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
/* initialize h5tools lib */
h5tools_init();
+ /* init linkinfo struct */
+ memset(&linkinfo, 0, sizeof(h5tool_link_info_t));
+
/* Check for no command line parameters */
if(argc == 1) {
usage();
@@ -406,12 +411,29 @@ main (int argc, const char *argv[])
if(verbose)
printf("%s: Creating parent groups\n", h5tools_getprogname());
} /* end if */
+ else /* error, if parent groups doesn't already exist in destination file */
+ {
+ len = strlen(oname_dst);
+ /* check if all the parents groups exist. skip root group */
+ for (i = 1; i < len-1; i++)
+ {
+ if ('/'==oname_dst[i])
+ {
+ str_prt = strndup(oname_dst, (size_t)i);
+ if (H5Lexists(fid_dst, str_prt, H5P_DEFAULT) <= 0)
+ {
+ error_msg("group <%s> doesn't exist. Use -p to create parent groups.\n", str_prt);
+ free(str_prt);
+ goto error;
+ }
+ free(str_prt);
+ }
+ }
+ }
/*-------------------------------------------------------------------------
* do the copy
*-------------------------------------------------------------------------*/
- /* init linkinfo struct */
- memset(&linkinfo, 0, sizeof(h5tool_link_info_t));
if(verbose)
linkinfo.opt.msg_mode = 1;