blob: 0947ef5cfaeb033a170faaac2cf81f36340b73ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/* rename.c
Rename a file to a new name (Unix specific implementation). */
#include "uucp.h"
#include "sysdep.h"
#include <errno.h>
/* This implementation will not work on directories, but fortunately
we never want to rename directories. */
int
rename (zfrom, zto)
const char *zfrom;
const char *zto;
{
if (link (zfrom, zto) < 0)
{
if (errno != EEXIST)
return -1;
if (unlink (zto) < 0
|| link (zfrom, zto) < 0)
return -1;
}
return unlink (zfrom);
}
|