1 /*
2 		    Language Independent Library
3 
4 	    Copyright 1983-2000 Green Hills Software,Inc.
5 
6  *  This program is the property of Green Hills Software, Inc,
7  *  its contents are proprietary information and no part of it
8  *  is to be disclosed to anyone except employees of Green Hills
9  *  Software, Inc., or as agreed in writing signed by the President
10  *  of Green Hills Software, Inc.
11 */
12 /* ind_renm.c: ANSI rename() facility. */
13 
14 #include "indos.h"
15 
16 /* If an external ANSI-compliant libc.a is available, it will have rename() */
17 #if !defined(LIBCISANSI)
18 /******************************************************************************/
19 /*  int rename(const char *old, const char *new);			      */
20 /*  Rename the file named "old" to the name "new".			      */
21 /*  Return 0 if the operation succeeds.  Return -1 if there is no such        */
22 /*  file or if the file cannot be renamed, and set errno appropriately	      */
23 /******************************************************************************/
rename(const char * old,const char * new)24 int rename(const char *old, const char *new) {
25 #if defined(EMBEDDED)
26 #pragma ghs nowarning 1547	/* Syscall prototypes might not match */
27     return __ghs_syscall(SYSCALL_RENAME, old, new);
28 #pragma ghs endnowarning 1547
29 #elif 0	/* no known systems still require this to be provided for them */
30     if (link(old, new)!=0)
31 	return(-1);
32     return(unlink(old));
33 #else
34 /*
35  *  If no other implementation is provided, return -1 (there are no files)
36  */
37     return(-1);
38 #endif
39 }
40 #endif	/* !LIBCISANSI */
41