diff options
author | jbj <devnull@localhost> | 2002-11-15 18:27:07 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-11-15 18:27:07 +0000 |
commit | c0e27af8c5dc9d209854ca9170995622652fc30c (patch) | |
tree | fbe8bada0e53ebcb9d9dafc7a66e2f44c10c4cec /db | |
parent | d3805810d30fb0a900ad73eb9104368ca2222641 (diff) | |
download | librpm-tizen-c0e27af8c5dc9d209854ca9170995622652fc30c.tar.gz librpm-tizen-c0e27af8c5dc9d209854ca9170995622652fc30c.tar.bz2 librpm-tizen-c0e27af8c5dc9d209854ca9170995622652fc30c.zip |
Apply patch.4.1.24.3:
3.Fix a link error ("GetLongPathNameA could not be located in the dynamic link library KERNEL32.dll") that prevented the Berkeley DB
4.1.24 release from loading on some Windows/NT systems.
CVS patchset: 5866
CVS date: 2002/11/15 18:27:07
Diffstat (limited to 'db')
-rw-r--r-- | db/os_win32/os_rename.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/db/os_win32/os_rename.c b/db/os_win32/os_rename.c index c82482046..e900af49f 100644 --- a/db/os_win32/os_rename.c +++ b/db/os_win32/os_rename.c @@ -1,57 +1,62 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997, 1998, 1999, 2000 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "$Id: os_rename.c,v 1.2 2000/06/13 19:52:19 dda Exp $"; +static const char revid[] = "Id: os_rename.c,v 1.12 2002/07/12 18:56:55 bostic Exp "; #endif /* not lint */ #include "db_int.h" -#include "os_jump.h" /* * __os_rename -- * Rename a file. */ int -__os_rename(dbenv, old, new) +__os_rename(dbenv, oldname, newname, flags) DB_ENV *dbenv; - const char *old, *new; + const char *oldname, *newname; + u_int32_t flags; { int ret; ret = 0; - if (__db_jump.j_rename != NULL) { - if (__db_jump.j_rename(old, new) == -1) + if (DB_GLOBAL(j_rename) != NULL) { + if (DB_GLOBAL(j_rename)(oldname, newname) == -1) ret = __os_get_errno(); + goto done; } - else { - /* Normally we would use a single MoveFileEx call with - * MOVEFILE_REPLACE_EXISTING flag to simulate Unix rename(). - * But if the target file exists, and the two files' 8.3 - * names are identical, a Windows bug causes the target file - * to be deleted, but the original file will not be renamed, - * and an ENOENT error will be returned. (See MSDN for a - * description of the bug). - * - * After the failed call, a MoveFile seems to perform - * the rename correctly (even another call to MoveFileEx - * does not)! The expense of this extra call only occurs - * on systems with the bug: Windows/98, for one, but - * apparently not Windows/NT and Windows/2000. - */ - if (MoveFileEx(old, new, MOVEFILE_REPLACE_EXISTING) != TRUE) - ret = __os_win32_errno(); - if (ret == ENOENT && MoveFile(old, new) == TRUE) - ret = 0; + + if (!MoveFile(oldname, newname)) + ret = __os_win32_errno(); + + if (ret == EEXIST) { + ret = 0; + if (__os_is_winnt()) { + if (!MoveFileEx( + oldname, newname, MOVEFILE_REPLACE_EXISTING)) + ret = __os_win32_errno(); + } else { + /* + * There is no MoveFileEx for Win9x/Me, so we have to + * do the best we can. Note that MoveFile returns 1 + * if the names refer to the same file, so we don't + * need to check that here. + */ + (void)DeleteFile(newname); + if (!MoveFile(oldname, newname)) + ret = __os_win32_errno(); + } } - if (ret != 0) - __db_err(dbenv, "Rename %s %s: %s", old, new, strerror(ret)); + +done: if (ret != 0 && flags == 0) + __db_err(dbenv, + "Rename %s %s: %s", oldname, newname, strerror(ret)); return (ret); } |