00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "ansidecl.h"
00016 #ifdef HAVE_CONFIG_H
00017 #include "config.h"
00018 #endif
00019 #include <errno.h>
00020 #ifdef HAVE_UNISTD_H
00021 #include <unistd.h>
00022 #endif
00023
00024 int
00025 rename (const char *zfrom, const char *zto)
00026 {
00027 if (link (zfrom, zto) < 0)
00028 {
00029 if (errno != EEXIST)
00030 return -1;
00031 if (unlink (zto) < 0
00032 || link (zfrom, zto) < 0)
00033 return -1;
00034 }
00035 return unlink (zfrom);
00036 }