summaryrefslogtreecommitdiffstats
path: root/gnu/libexec/uucp/libunix/rename.c
diff options
context:
space:
mode:
authorconklin <conklin@FreeBSD.org>1993-08-05 18:28:27 +0000
committerconklin <conklin@FreeBSD.org>1993-08-05 18:28:27 +0000
commit9445dd12015987ffafa05df26c1bcd0f39c1dd70 (patch)
tree64cb2831b24d3f5002a9a9ec1426e82c6d6bb5d4 /gnu/libexec/uucp/libunix/rename.c
parentf0d11b6bf5fa75bb5f59b57795dcd450a1bf433b (diff)
downloadFreeBSD-src-9445dd12015987ffafa05df26c1bcd0f39c1dd70.zip
FreeBSD-src-9445dd12015987ffafa05df26c1bcd0f39c1dd70.tar.gz
Taylor UUCP 1.04
Diffstat (limited to 'gnu/libexec/uucp/libunix/rename.c')
-rw-r--r--gnu/libexec/uucp/libunix/rename.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gnu/libexec/uucp/libunix/rename.c b/gnu/libexec/uucp/libunix/rename.c
new file mode 100644
index 0000000..0947ef5
--- /dev/null
+++ b/gnu/libexec/uucp/libunix/rename.c
@@ -0,0 +1,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);
+}
OpenPOWER on IntegriCloud