Imported from ../bash-2.03.tar.gz.
[platform/upstream/bash.git] / lib / sh / rename.c
1 /*
2  * rename - rename a file
3  */
4
5 #include <config.h>
6
7 #if !defined (HAVE_RENAME)
8
9 #include <bashtypes.h>
10
11 #if defined (HAVE_UNISTD_H)
12 #  include <unistd.h>
13 #endif
14
15 #include <stdc.h>
16
17 int
18 rename (from, to)
19      const char *from, *to;
20 {
21   unlink (to);
22   if (link (from, to) < 0)
23     return (-1);
24   unlink (from);
25   return (0);
26 }
27 #endif /* !HAVE_RENAME */