From e7f05951a00b513113dd92d3caee3ee4c4c7e477 Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 4 Mar 2002 18:03:51 +0000 Subject: Check if the output file already exists - and open it in append mode then. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@106 4825ed28-b72c-4eae-9704-e50c059e567d --- src/util/hdf5_extract.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/util/hdf5_extract.c b/src/util/hdf5_extract.c index 5f1caf0..70e63b4 100644 --- a/src/util/hdf5_extract.c +++ b/src/util/hdf5_extract.c @@ -124,8 +124,13 @@ int main (int argc, char *argv[]) return (-1); } - /* create output file */ - outfile = H5Fcreate (argv[3], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + /* try to open an existing outfile file in append mode, + if this fails create it as a new file */ + outfile = H5Fopen (argv[3], H5F_ACC_RDWR, H5P_DEFAULT); + if (outfile < 0) + { + outfile = H5Fcreate (argv[3], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + } if (outfile < 0) { fprintf (stderr, "ERROR: Cannot create HDF5 output file '%s' !\n\n", @@ -239,7 +244,7 @@ static herr_t CopyObject (hid_t from, if (result < 0) { fprintf (stderr, "WARNING: object '%s' will not be extracted (object " - "does't exist)\n", objectname); + "doesn't exist)\n", objectname); nerrors++; return (0); } -- cgit v1.2.3