1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1997,2008 Oracle. All rights reserved. 5 * 6 * $Id: os_rename.c,v 12.13 2008/02/18 19:34:21 bostic Exp $ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12 13/* 14 * __os_rename -- 15 * Rename a file. 16 * 17 * PUBLIC: int __os_rename __P((ENV *, 18 * PUBLIC: const char *, const char *, u_int32_t)); 19 */ 20int 21__os_rename(env, oldname, newname, silent) 22 ENV *env; 23 const char *oldname, *newname; 24 u_int32_t silent; 25{ 26 DB_ENV *dbenv; 27 int ret; 28 29 dbenv = env == NULL ? NULL : env->dbenv; 30 if (dbenv != NULL && 31 FLD_ISSET(dbenv->verbose, DB_VERB_FILEOPS | DB_VERB_FILEOPS_ALL)) 32 __db_msg(env, "fileops: rename %s to %s", oldname, newname); 33 34 LAST_PANIC_CHECK_BEFORE_IO(env); 35 36 if (DB_GLOBAL(j_rename) != NULL) 37 ret = DB_GLOBAL(j_rename)(oldname, newname); 38 else 39 RETRY_CHK((rename(oldname, newname)), ret); 40 41 /* 42 * If "silent" is not set, then errors are OK and we should not output 43 * an error message. 44 */ 45 if (ret != 0) { 46 if (!silent) 47 __db_syserr( 48 env, ret, "rename %s %s", oldname, newname); 49 ret = __os_posix_err(ret); 50 } 51 return (ret); 52} 53