xref: /onnv-gate/usr/src/lib/libresolv2/common/isc/movefile.c (revision 11038:74b12212b8a2)
1*11038SRao.Shoaib@Sun.COM /*
2*11038SRao.Shoaib@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3*11038SRao.Shoaib@Sun.COM  * Use is subject to license terms.
4*11038SRao.Shoaib@Sun.COM  */
5*11038SRao.Shoaib@Sun.COM 
6*11038SRao.Shoaib@Sun.COM 
7*11038SRao.Shoaib@Sun.COM /*
8*11038SRao.Shoaib@Sun.COM  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
9*11038SRao.Shoaib@Sun.COM  * Copyright (c) 2000 by Internet Software Consortium, Inc.
10*11038SRao.Shoaib@Sun.COM  *
11*11038SRao.Shoaib@Sun.COM  * Permission to use, copy, modify, and distribute this software for any
12*11038SRao.Shoaib@Sun.COM  * purpose with or without fee is hereby granted, provided that the above
13*11038SRao.Shoaib@Sun.COM  * copyright notice and this permission notice appear in all copies.
14*11038SRao.Shoaib@Sun.COM  *
15*11038SRao.Shoaib@Sun.COM  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
16*11038SRao.Shoaib@Sun.COM  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17*11038SRao.Shoaib@Sun.COM  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
18*11038SRao.Shoaib@Sun.COM  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19*11038SRao.Shoaib@Sun.COM  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20*11038SRao.Shoaib@Sun.COM  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21*11038SRao.Shoaib@Sun.COM  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22*11038SRao.Shoaib@Sun.COM  */
23*11038SRao.Shoaib@Sun.COM 
24*11038SRao.Shoaib@Sun.COM 
25*11038SRao.Shoaib@Sun.COM #include <port_before.h>
26*11038SRao.Shoaib@Sun.COM #include <stdio.h>
27*11038SRao.Shoaib@Sun.COM #include <isc/misc.h>
28*11038SRao.Shoaib@Sun.COM #include <port_after.h>
29*11038SRao.Shoaib@Sun.COM #ifndef HAVE_MOVEFILE
30*11038SRao.Shoaib@Sun.COM /*
31*11038SRao.Shoaib@Sun.COM  * rename() is lame (can't overwrite an existing file) on some systems.
32*11038SRao.Shoaib@Sun.COM  * use movefile() instead, and let lame OS ports do what they need to.
33*11038SRao.Shoaib@Sun.COM  */
34*11038SRao.Shoaib@Sun.COM 
35*11038SRao.Shoaib@Sun.COM int
isc_movefile(const char * oldname,const char * newname)36*11038SRao.Shoaib@Sun.COM isc_movefile(const char *oldname, const char *newname) {
37*11038SRao.Shoaib@Sun.COM 	return (rename(oldname, newname));
38*11038SRao.Shoaib@Sun.COM }
39*11038SRao.Shoaib@Sun.COM #else
40*11038SRao.Shoaib@Sun.COM 	static int os_port_has_isc_movefile = 1;
41*11038SRao.Shoaib@Sun.COM #endif
42*11038SRao.Shoaib@Sun.COM 
43*11038SRao.Shoaib@Sun.COM /*! \file */
44