aboutsummaryrefslogtreecommitdiff
path: root/src/DumpGH.c
diff options
context:
space:
mode:
authortradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2001-06-22 10:55:20 +0000
committertradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2001-06-22 10:55:20 +0000
commit5e8954e2ebdd504c7dbaaa7dc45b5dbdcd6f18f3 (patch)
tree1afbd51d23e6151ac5f9ee537611830bf9092988 /src/DumpGH.c
parenta4a9bf3387a6945d40b87e1304a4dc24aea7220e (diff)
Unlink an existing file before renaming a temporary cp file to it.
This is needed for Windows where rename(2) isn't POSIX compatible. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@206 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/DumpGH.c')
-rw-r--r--src/DumpGH.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/DumpGH.c b/src/DumpGH.c
index d8afb46..ccdf9c1 100644
--- a/src/DumpGH.c
+++ b/src/DumpGH.c
@@ -11,10 +11,6 @@
@@*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
#include "cctk.h"
#include "cctk_Version.h"
#include "cctk_Parameters.h"
@@ -22,6 +18,13 @@
#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h"
#include "ioFlexGH.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
/* the rcs ID and its dummy funtion to use it */
static const char *rcsid = "$Id$";
CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_DumpGH_c)
@@ -418,6 +421,11 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from)
CCTK_VInfo (CCTK_THORNSTRING, "Closing and renaming checkpoint file "
"into '%s'", dumpfname);
+#ifdef _WIN32
+ /* Windows' rename(2) routine isn't POSIX compatible in that it would
+ unlink an existing file */
+ unlink (dumpfname);
+#endif
if (rename (tmpfname, dumpfname))
CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
"Could not rename temporary checkpoint file %s to %s",