summaryrefslogtreecommitdiff
path: root/src/internal/slibtool_objmeta_impl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/slibtool_objmeta_impl.c')
-rw-r--r--src/internal/slibtool_objmeta_impl.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/internal/slibtool_objmeta_impl.c b/src/internal/slibtool_objmeta_impl.c
index 9e9353b..09a6c97 100644
--- a/src/internal/slibtool_objmeta_impl.c
+++ b/src/internal/slibtool_objmeta_impl.c
@@ -4,8 +4,10 @@
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
/*******************************************************************/
+#include <fcntl.h>
#include <stdio.h>
#include <slibtool/slibtool.h>
+#include "slibtool_dprintf_impl.h"
#include "slibtool_errinfo_impl.h"
#include "slibtool_metafile_impl.h"
@@ -14,15 +16,19 @@ static int slbt_create_default_object_wrapper(
struct slbt_exec_ctx * ectx)
{
int ret;
- FILE * fout;
+ int fdout;
const struct slbt_source_version * verinfo;
- if (!(fout = fopen(ectx->ltobjname,"w")))
+ if ((fdout = openat(
+ AT_FDCWD,
+ ectx->ltobjname,
+ O_RDWR|O_CREAT|O_TRUNC,
+ 0644)) < 0)
return SLBT_SYSTEM_ERROR(dctx);
verinfo = slbt_source_version();
- ret = fprintf(fout,
+ ret = slbt_dprintf(fdout,
"# libtool compatible object wrapper\n"
"# Generated by %s (slibtool %d.%d.%d)\n"
"# [commit reference: %s]\n\n"
@@ -41,9 +47,9 @@ static int slbt_create_default_object_wrapper(
? ectx->aobjname
: "none");
- return (ret <= 0) || fclose(fout)
- ? SLBT_SYSTEM_ERROR(dctx)
- : 0;
+ close(fdout);
+
+ return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0;
}
static int slbt_create_compatible_object_wrapper(