diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-02-13 22:42:43 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-02-13 22:42:43 (GMT) |
commit | d3c5ab50fc8fba8ff72417b125feaac8a3faed68 (patch) | |
tree | 541b46eca7b891581a3d29808806db8dfa73906c /tools/h5copy/h5copy.c | |
parent | 1603adeaee43e22b61055633c1dc2250aaa3a922 (diff) | |
download | hdf5-d3c5ab50fc8fba8ff72417b125feaac8a3faed68.zip hdf5-d3c5ab50fc8fba8ff72417b125feaac8a3faed68.tar.gz hdf5-d3c5ab50fc8fba8ff72417b125feaac8a3faed68.tar.bz2 |
[svn-r13292] Description:
Add feature to h5copy to allow it to add an object to an existing file,
instead of blowing away existing file.
Modify h5tools_fopen() routine to take access flags, so it can be used
to open an existing file for writing.
Added check to h5copy test script that verifies it has produced a file
with the correct structure.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'tools/h5copy/h5copy.c')
-rw-r--r-- | tools/h5copy/h5copy.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c index 5ca21e5..9b4f629 100644 --- a/tools/h5copy/h5copy.c +++ b/tools/h5copy/h5copy.c @@ -272,7 +272,7 @@ main (int argc, const char *argv[]) * open input file *-------------------------------------------------------------------------*/ - fid_src = h5tools_fopen(fname_src, NULL, NULL, 0); + fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, NULL, NULL, 0); /*------------------------------------------------------------------------- * test for error in opening input file @@ -289,7 +289,13 @@ main (int argc, const char *argv[]) * open output file *-------------------------------------------------------------------------*/ - fid_dst = H5Fcreate(fname_dst, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + /* Attempt to open an existing HDF5 file first */ + fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, 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) + fid_dst = H5Fcreate(fname_dst, H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- * test for error in opening output file |