* expr.c (expand_expr): Revove bogus conditional.
[official-gcc.git] / libiberty / rename.c
blob2e9dec18fa1d38c50fbaaf5956bbcb9e24192d50
1 /* rename -- rename a file
2 This function is in the public domain. */
4 /* Rename a file. */
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif
9 #include <errno.h>
10 #ifdef HAVE_UNISTD_H
11 #include <unistd.h>
12 #endif
14 int
15 rename (zfrom, zto)
16 char *zfrom;
17 char *zto;
19 if (link (zfrom, zto) < 0)
21 if (errno != EEXIST)
22 return -1;
23 if (unlink (zto) < 0
24 || link (zfrom, zto) < 0)
25 return -1;
27 return unlink (zfrom);