|
|
1.1 ! root 1: /* rename.c ! 2: Rename a file to a new name (Unix specific implementation). */ ! 3: ! 4: #include "uucp.h" ! 5: ! 6: #include "sysdep.h" ! 7: ! 8: #include <errno.h> ! 9: ! 10: /* This implementation will not work on directories, but fortunately ! 11: we never want to rename directories. */ ! 12: ! 13: int ! 14: rename (zfrom, zto) ! 15: const char *zfrom; ! 16: const char *zto; ! 17: { ! 18: if (link (zfrom, zto) < 0) ! 19: { ! 20: if (errno != EEXIST) ! 21: return -1; ! 22: if (unlink (zto) < 0 ! 23: || link (zfrom, zto) < 0) ! 24: return -1; ! 25: } ! 26: return unlink (zfrom); ! 27: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.