summaryrefslogtreecommitdiffstats
path: root/tools/h5copy/h5copy.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2011-03-09 15:26:20 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2011-03-09 15:26:20 (GMT)
commit6dd040b2717ff3afc66b9ffebb4cc679533b37b8 (patch)
tree12770a4f0f37f64d8706f196cb044b3d548445c6 /tools/h5copy/h5copy.c
parent8b8637d014f76f33b6e1c07a3fa5200dfe4fa200 (diff)
downloadhdf5-6dd040b2717ff3afc66b9ffebb4cc679533b37b8.zip
hdf5-6dd040b2717ff3afc66b9ffebb4cc679533b37b8.tar.gz
hdf5-6dd040b2717ff3afc66b9ffebb4cc679533b37b8.tar.bz2
[svn-r20210] Purpose:
Fix Bug 2120 - h5copy: improve to copy an object into same HDF file Description: Merged from HDF5 trunk r20203. Before the fix users can't copy an object (dataset or group) with different name if input file (-i) and output file (-o) is same. This feature would be useful to clone any object with different name and reuse contents. Tested: jam (linux32-LE), amani (linux64-LE), heiwa (linuxppc64-BE), Cmake (jam)
Diffstat (limited to 'tools/h5copy/h5copy.c')
-rw-r--r--tools/h5copy/h5copy.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index 3760d6f..fb8bb81 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -319,6 +319,14 @@ main (int argc, const char *argv[])
leave(EXIT_FAILURE);
}
+ /*-------------------------------------------------------------------------
+ * open output file
+ *-------------------------------------------------------------------------*/
+
+ /* Attempt to open an existing HDF5 file first. Need to open the dst file
+ before the src file just in case that the dst and src are the same file
+ */
+ fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0);
/*-------------------------------------------------------------------------
* open input file
@@ -337,13 +345,11 @@ main (int argc, const char *argv[])
leave(EXIT_FAILURE);
}
+
/*-------------------------------------------------------------------------
- * open output file
+ * create an output file when failed to open it
*-------------------------------------------------------------------------*/
- /* Attempt to open an existing HDF5 file first */
- fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0);
-
/* If we couldn't open an existing file, try creating file */
/* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
if(fid_dst < 0)