Use MoveFileEx if it exists (which means we're on Windows and rename is broken).
XXX: We need a better naming scheme for internal replacement functions.

--HG--
branch : HEAD
diff --git a/lib/zip_close.c b/lib/zip_close.c
index df9c1d1..326c26f 100644
--- a/lib/zip_close.c
+++ b/lib/zip_close.c
@@ -1,6 +1,6 @@
 /*
   zip_close.c -- close zip archive and update changes
-  Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -229,7 +229,7 @@
 	za->zp = NULL;
 	reopen_on_error = 1;
     }
-    if (rename(temp, za->zn) != 0) {
+    if (_zip_rename(temp, za->zn) != 0) {
 	_zip_error_set(&za->error, ZIP_ER_RENAME, errno);
 	remove(temp);
 	free(temp);
diff --git a/lib/zipint.h b/lib/zipint.h
index f5f7b56..470e585 100644
--- a/lib/zipint.h
+++ b/lib/zipint.h
@@ -3,7 +3,7 @@
 
 /*
   zipint.h -- internal declarations.
-  Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -48,6 +48,15 @@
 #define mkstemp _zip_mkstemp
 #endif
 
+#ifdef HAVE_MOVEFILEEX
+#include <windows.h>
+#define _zip_rename(s, t)						\
+	(!MoveFileEx((s), (t),						\
+		     MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
+#else
+#define _zip_rename	rename
+#endif
+
 #ifndef HAVE_FSEEKO
 #define fseeko(s, o, w)	(fseek((s), (long int)(o), (w)))
 #endif