2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1997-2001
5
* Sleepycat Software. All rights reserved.
11
static const char revid[] = "$Id: os_rename.c,v 1.3 2001/01/25 18:23:00 bostic Exp $";
22
__os_rename(dbenv, old, new)
24
const char *old, *new;
29
if (__db_jump.j_rename != NULL) {
30
if (__db_jump.j_rename(old, new) == -1)
31
ret = __os_get_errno();
34
/* Normally we would use a single MoveFileEx call with
35
* MOVEFILE_REPLACE_EXISTING flag to simulate Unix rename().
36
* But if the target file exists, and the two files' 8.3
37
* names are identical, a Windows bug causes the target file
38
* to be deleted, but the original file will not be renamed,
39
* and an ENOENT error will be returned. (See MSDN for a
40
* description of the bug).
42
* After the failed call, a MoveFile seems to perform
43
* the rename correctly (even another call to MoveFileEx
44
* does not)! The expense of this extra call only occurs
45
* on systems with the bug: Windows/98, for one, but
46
* apparently not Windows/NT and Windows/2000.
48
if (MoveFileEx(old, new, MOVEFILE_REPLACE_EXISTING) != TRUE)
49
ret = __os_win32_errno();
50
if (ret == ENOENT && MoveFile(old, new) == TRUE)
54
__db_err(dbenv, "Rename %s %s: %s", old, new, strerror(ret));