summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/slibtool/slibtool.h2
-rw-r--r--project/common.mk1
-rw-r--r--src/helper/slbt_copy_file.c38
3 files changed, 41 insertions, 0 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index 70ceef9..533be58 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -217,6 +217,8 @@ slbt_api int slbt_map_input (int fd, const char * path, int prot, struct slbt_
slbt_api int slbt_unmap_input (struct slbt_input *);
slbt_api int slbt_archive_import (const struct slbt_driver_ctx *, struct slbt_exec_ctx *,
char * dstarchive, char * srcarchive);
+slbt_api int slbt_copy_file (const struct slbt_driver_ctx *, struct slbt_exec_ctx *,
+ char * src, char * dst);
/* utility api */
slbt_api int slbt_output_config (const struct slbt_driver_ctx *);
diff --git a/project/common.mk b/project/common.mk
index ae06f28..6a8c3f1 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -3,6 +3,7 @@ COMMON_SRCS = \
src/driver/slbt_driver_ctx.c \
src/driver/slbt_unit_ctx.c \
src/helper/slbt_archive_import.c \
+ src/helper/slbt_copy_file.c \
src/logic/slbt_exec_compile.c \
src/logic/slbt_exec_ctx.c \
src/logic/slbt_exec_install.c \
diff --git a/src/helper/slbt_copy_file.c b/src/helper/slbt_copy_file.c
new file mode 100644
index 0000000..fb44dc7
--- /dev/null
+++ b/src/helper/slbt_copy_file.c
@@ -0,0 +1,38 @@
+/*******************************************************************/
+/* slibtool: a skinny libtool implementation, written in C */
+/* Copyright (C) 2016 Z. Gilboa */
+/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
+/*******************************************************************/
+
+#include <slibtool/slibtool.h>
+#include "slibtool_spawn_impl.h"
+
+int slbt_copy_file(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx,
+ char * src,
+ char * dst)
+{
+ char * cp[4];
+
+ /* cp argv */
+ cp[0] = "cp";
+ cp[1] = src;
+ cp[2] = dst;
+ cp[3] = 0;
+
+ /* alternate argument vector */
+ ectx->argv = cp;
+ ectx->program = "cp";
+
+ /* step output */
+ if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
+ if (slbt_output_link(dctx,ectx))
+ return -1;
+
+ /* dlltool spawn */
+ if ((slbt_spawn(ectx,true) < 0) || ectx->exitcode)
+ return -1;
+
+ return 0;
+}