aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-03-04 18:03:51 +0000
committertradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-03-04 18:03:51 +0000
commite7f05951a00b513113dd92d3caee3ee4c4c7e477 (patch)
tree2c6a6e5b2eaaa445be2f107d81c29e7917ca2ca5
parent91f29c7f9ea41731286fa36f7f3696437228dfb2 (diff)
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
-rw-r--r--src/util/hdf5_extract.c11
1 files changed, 8 insertions, 3 deletions
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);
}