summaryrefslogtreecommitdiff
path: root/lib/sh/rename.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sh/rename.c')
-rw-r--r--lib/sh/rename.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/sh/rename.c b/lib/sh/rename.c
new file mode 100644
index 00000000..799cb697
--- /dev/null
+++ b/lib/sh/rename.c
@@ -0,0 +1,27 @@
+/*
+ * rename - rename a file
+ */
+
+#include <config.h>
+
+#if !defined (HAVE_RENAME)
+
+#include <bashtypes.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include <stdc.h>
+
+int
+rename (from, to)
+ const char *from, *to;
+{
+ unlink (to);
+ if (link (from, to) < 0)
+ return (-1);
+ unlink (from);
+ return (0);
+}
+#endif /* !HAVE_RENAME */