summaryrefslogtreecommitdiffhomepage
path: root/src/util
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-21 06:18:44 +0000
committermidipix <writeonce@midipix.org>2024-02-21 06:18:44 +0000
commitfc7ad9f9947b5097e1a246b009b487d3206fd588 (patch)
treeaca1e2b8f1099337d76db36afc83cbeba4750b8a /src/util
parent5b993e0818b603c1dec4126dfe45c617619eff93 (diff)
downloadslibtool-fc7ad9f9947b5097e1a246b009b487d3206fd588.tar.bz2
slibtool-fc7ad9f9947b5097e1a246b009b487d3206fd588.tar.xz
slbt_util_copy_file(): simplify interface.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/slbt_copy_file.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/util/slbt_copy_file.c b/src/util/slbt_copy_file.c
index e6868de..3fa0074 100644
--- a/src/util/slbt_copy_file.c
+++ b/src/util/slbt_copy_file.c
@@ -11,24 +11,39 @@
#include "slibtool_errinfo_impl.h"
int slbt_util_copy_file(
- const struct slbt_driver_ctx * dctx,
- struct slbt_exec_ctx * ectx,
- char * src,
- char * dst)
+ struct slbt_exec_ctx * ectx,
+ const char * from,
+ const char * to)
{
+ int ret;
int fdcwd;
char ** oargv;
char * oprogram;
+ char * src;
+ char * dst;
char * cp[4];
- int ret;
+
+ const struct slbt_driver_ctx * dctx;
+
+ /* driver context */
+ dctx = (slbt_get_exec_ictx(ectx))->dctx;
/* fdcwd */
fdcwd = slbt_driver_fdcwd(dctx);
/* placeholder? */
- if (slbt_symlink_is_a_placeholder(fdcwd,src))
+ if (slbt_symlink_is_a_placeholder(fdcwd,from))
return 0;
+ /* until we perform an in-memory copy ... */
+ if (!(src = strdup(from)))
+ return SLBT_SYSTEM_ERROR(dctx,0);
+
+ if (!(dst = strdup(to))) {
+ free(src);
+ return SLBT_SYSTEM_ERROR(dctx,0);
+ }
+
/* cp argv */
cp[0] = "cp";
cp[1] = src;
@@ -47,12 +62,14 @@ int slbt_util_copy_file(
if (slbt_output_link(ectx)) {
ectx->argv = oargv;
ectx->program = oprogram;
+ free(src); free(dst);
return SLBT_NESTED_ERROR(dctx);
}
} else {
if (slbt_output_install(ectx)) {
ectx->argv = oargv;
ectx->program = oprogram;
+ free(src); free(dst);
return SLBT_NESTED_ERROR(dctx);
}
}
@@ -70,6 +87,9 @@ int slbt_util_copy_file(
ret = 0;
}
+ free(src);
+ free(dst);
+
ectx->argv = oargv;
ectx->program = oprogram;
return ret;