summaryrefslogtreecommitdiff
path: root/gnu/lib/libg++/libiberty/rename.c
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-03-15 22:20:43 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-03-15 22:20:43 +0000
commit46b17fd21b2b16c60c2d0c242ed15fad6ab17fc6 (patch)
treec15d088d219cbc2963bcc42c35634a9e4bb296c9 /gnu/lib/libg++/libiberty/rename.c
parentf534d44ccdb17011802f89b9ad24fa0712693698 (diff)
Import of GNU libg++ 2.7.1 port (prepared by Erik Theisen)
Diffstat (limited to 'gnu/lib/libg++/libiberty/rename.c')
-rw-r--r--gnu/lib/libg++/libiberty/rename.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gnu/lib/libg++/libiberty/rename.c b/gnu/lib/libg++/libiberty/rename.c
new file mode 100644
index 00000000000..ae26e2d0040
--- /dev/null
+++ b/gnu/lib/libg++/libiberty/rename.c
@@ -0,0 +1,22 @@
+/* rename -- rename a file
+ This function is in the public domain. */
+
+/* Rename a file. */
+
+#include <errno.h>
+
+int
+rename (zfrom, zto)
+ char *zfrom;
+ 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);
+}