1 /***********************************************************************/
5 /* Contributed by Tracy Camp, PolyServe Inc., <campt@polyserve.com> */
7 /* Copyright 2002 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../../LICENSE. */
12 /***********************************************************************/
14 /* $Id: rename.c 6553 2004-07-13 12:25:21Z xleroy $ */
18 #include "unixsupport.h"
20 CAMLprim value unix_rename(value path1, value path2)
22 static int supports_MoveFileEx = -1; /* don't know yet */
25 if (supports_MoveFileEx < 0) {
26 OSVERSIONINFO VersionInfo;
27 VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
29 (GetVersionEx(&VersionInfo) != 0)
30 && (VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
32 if (supports_MoveFileEx > 0)
33 ok = MoveFileEx(String_val(path1), String_val(path2),
34 MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH |
35 MOVEFILE_COPY_ALLOWED);
37 ok = MoveFile(String_val(path1), String_val(path2));
39 win32_maperr(GetLastError());
40 uerror("rename", path1);