diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2010-10-14 20:47:20 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2010-10-14 20:47:20 (GMT) |
commit | 08e13006257ad085b9b00c8627bfa8a85d0c7cde (patch) | |
tree | ded7ebd6250308df968ea8251f2eb18088801f96 /tools/h5copy/h5copy.c | |
parent | 504e07759ef8f916a754c4a31195774d7b77eb4e (diff) | |
download | hdf5-08e13006257ad085b9b00c8627bfa8a85d0c7cde.zip hdf5-08e13006257ad085b9b00c8627bfa8a85d0c7cde.tar.gz hdf5-08e13006257ad085b9b00c8627bfa8a85d0c7cde.tar.bz2 |
[svn-r19598] 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. Expected to be failed.
Tested:
jam, amani, heiwa
Diffstat (limited to 'tools/h5copy/h5copy.c')
-rw-r--r-- | tools/h5copy/h5copy.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c index eb16754..595864e 100644 --- a/tools/h5copy/h5copy.c +++ b/tools/h5copy/h5copy.c @@ -215,6 +215,8 @@ 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); @@ -406,6 +408,23 @@ 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"); + goto error; + } + } + } + } /*------------------------------------------------------------------------- * do the copy @@ -459,6 +478,8 @@ main (int argc, const char *argv[]) free(oname_dst); if (oname_src) free(oname_src); + if (str_prt) + free(str_prt); h5tools_close(); @@ -485,6 +506,8 @@ error: free(oname_dst); if (oname_src) free(oname_src); + if (str_prt) + free(str_prt); h5tools_close(); |