Last change
on this file was 610, checked in by bird, 22 years ago |
This commit was generated by cvs2svn to compensate for changes in r609,
which included commits to RCS files with non-trunk default branches.
|
-
Property cvs2svn:cvs-rev
set to
1.1.1.2
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
655 bytes
|
Line | |
---|
1 | /* rename -- rename a file
|
---|
2 | This function is in the public domain. */
|
---|
3 |
|
---|
4 | /*
|
---|
5 |
|
---|
6 | @deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new})
|
---|
7 |
|
---|
8 | Renames a file from @var{old} to @var{new}. If @var{new} already
|
---|
9 | exists, it is removed.
|
---|
10 |
|
---|
11 | @end deftypefn
|
---|
12 |
|
---|
13 | */
|
---|
14 |
|
---|
15 | #include "ansidecl.h"
|
---|
16 | #ifdef HAVE_CONFIG_H
|
---|
17 | #include "config.h"
|
---|
18 | #endif
|
---|
19 | #include <errno.h>
|
---|
20 | #ifdef HAVE_UNISTD_H
|
---|
21 | #include <unistd.h>
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | int
|
---|
25 | rename (zfrom, zto)
|
---|
26 | const char *zfrom;
|
---|
27 | const char *zto;
|
---|
28 | {
|
---|
29 | if (link (zfrom, zto) < 0)
|
---|
30 | {
|
---|
31 | if (errno != EEXIST)
|
---|
32 | return -1;
|
---|
33 | if (unlink (zto) < 0
|
---|
34 | || link (zfrom, zto) < 0)
|
---|
35 | return -1;
|
---|
36 | }
|
---|
37 | return unlink (zfrom);
|
---|
38 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.