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 (zfrom, zto)
00026 const char *zfrom;
00027 const char *zto;
00028 {
00029 if (link (zfrom, zto) < 0)
00030 {
00031 if (errno != EEXIST)
00032 return -1;
00033 if (unlink (zto) < 0
00034 || link (zfrom, zto) < 0)
00035 return -1;
00036 }
00037 return unlink (zfrom);
00038 }