1999-11-02 Scott Snyder <snyder@fnal.gov>
[official-gcc.git] / libiberty / rename.c
blobae26e2d004079e0e955369cb5f8982bf76ee9037
1 /* rename -- rename a file
2 This function is in the public domain. */
4 /* Rename a file. */
6 #include <errno.h>
8 int
9 rename (zfrom, zto)
10 char *zfrom;
11 char *zto;
13 if (link (zfrom, zto) < 0)
15 if (errno != EEXIST)
16 return -1;
17 if (unlink (zto) < 0
18 || link (zfrom, zto) < 0)
19 return -1;
21 return unlink (zfrom);